Skip to content

Commit 55289ad

Browse files
clean code
1 parent a1f2ad5 commit 55289ad

3 files changed

Lines changed: 7 additions & 29 deletions

File tree

paimon-python/pypaimon/read/reader/concat_batch_reader.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,19 @@ def read_arrow_batch(self) -> Optional[RecordBatch]:
210210
batch_index = self.row_offsets[i]
211211
field_index = self.field_offsets[i]
212212
field_name = self.schema.field(i).name
213-
column = None
214213

215214
if batch_index >= 0 and batches[batch_index] is not None:
216215
src_batch = batches[batch_index]
217-
if field_name is not None and field_name in src_batch.schema.names:
216+
if field_name in src_batch.schema.names:
218217
column = src_batch.column(
219218
src_batch.schema.get_field_index(field_name)
220219
).slice(0, min_rows)
221-
elif field_index < src_batch.num_columns:
222-
column = src_batch.column(field_index).slice(0, min_rows)
223-
224-
if column is None and field_name is not None:
225-
for b in batches:
226-
if b is not None and field_name in b.schema.names:
227-
column = b.column(b.schema.get_field_index(field_name)).slice(
228-
0, min_rows
229-
)
230-
break
231-
232-
if column is not None:
233-
columns.append(column)
234-
elif self.schema is not None and i < len(self.schema):
220+
columns.append(column)
221+
else:
222+
# Field doesn't exist in this batch, fill with nulls
223+
columns.append(pa.nulls(min_rows, type=self.schema.field(i).type))
224+
else:
225+
# No batch provides this field, fill with nulls
235226
columns.append(pa.nulls(min_rows, type=self.schema.field(i).type))
236227

237228
for i in range(len(self.readers)):

paimon-python/pypaimon/read/split_read.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,15 +806,6 @@ def _use_requested_field_names_for_merge(self, fields_files: List[FieldBunch]) -
806806
def _create_file_reader(self, file: DataFileMeta, read_fields: [str],
807807
use_requested_field_names: bool = True) -> Optional[RecordReader]:
808808
"""Create a file reader for a single file."""
809-
shard_file_idx_map = (
810-
self.split.shard_file_idx_map() if isinstance(self.split, SlicedSplit) else {}
811-
)
812-
begin_pos, end_pos = 0, 0
813-
if file.file_name in shard_file_idx_map:
814-
(begin_pos, end_pos) = shard_file_idx_map[file.file_name]
815-
if (begin_pos, end_pos) == (-1, -1):
816-
return None
817-
818809
def create_record_reader():
819810
return self.file_reader_supplier(
820811
file=file,
@@ -824,8 +815,6 @@ def create_record_reader():
824815
use_requested_field_names=use_requested_field_names)
825816

826817
base = create_record_reader()
827-
if file.file_name in shard_file_idx_map:
828-
base = ShardBatchReader(base, begin_pos, end_pos)
829818
if self.row_ranges is None:
830819
return base
831820
file_range = file.row_id_range()

paimon-python/pypaimon/read/table_read.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def _try_to_pad_batch_by_schema(batch: pyarrow.RecordBatch, target_schema):
6868
for field in target_schema:
6969
if field.name in batch.schema.names:
7070
col = batch.column(field.name)
71-
if col.type != field.type:
72-
col = pyarrow.nulls(num_rows, type=field.type)
7371
else:
7472
col = pyarrow.nulls(num_rows, type=field.type)
7573
columns.append(col)

0 commit comments

Comments
 (0)