Skip to content

Commit 074786d

Browse files
committed
fixing comments, thanks all :)
1 parent b2e16e9 commit 074786d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

pyiceberg/table/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def _set_ref_snapshot(
355355
return updates, requirements
356356

357357
def _build_partition_predicate(
358-
self, partition_records: set[Record], spec: PartitionSpec | None = None, schema: Schema | None = None
358+
self, partition_records: set[Record], spec: PartitionSpec, schema: Schema
359359
) -> BooleanExpression:
360360
"""Build a filter predicate matching any of the input partition records.
361361
@@ -366,9 +366,7 @@ def _build_partition_predicate(
366366
Returns:
367367
A predicate matching any of the input partition records.
368368
"""
369-
partition_spec = spec or self.table_metadata.spec()
370-
schema = schema or self.table_metadata.schema()
371-
partition_fields = [schema.find_field(field.source_id).name for field in partition_spec.fields]
369+
partition_fields = [schema.find_field(field.source_id).name for field in spec.fields]
372370

373371
expr: BooleanExpression = AlwaysFalse()
374372
for partition_record in partition_records:
@@ -545,7 +543,9 @@ def dynamic_partition_overwrite(
545543
)
546544

547545
partitions_to_overwrite = {data_file.partition for data_file in data_files}
548-
delete_filter = self._build_partition_predicate(partition_records=partitions_to_overwrite)
546+
delete_filter = self._build_partition_predicate(
547+
partition_records=partitions_to_overwrite, spec=self.table_metadata.spec(), schema=self.table_metadata.schema()
548+
)
549549
self.delete(delete_filter=delete_filter, snapshot_properties=snapshot_properties, branch=branch)
550550

551551
with self._append_snapshot_producer(snapshot_properties, branch=branch) as append_files:

pyiceberg/table/update/snapshot.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,7 @@ def _commit(self) -> UpdatesAndRequirements:
331331
def snapshot_id(self) -> int:
332332
return self._snapshot_id
333333

334-
def schema(self, schema_id: int | None = None) -> Schema:
335-
if schema_id:
336-
if schema := self._transaction.table_metadata.schema_by_id(schema_id):
337-
return schema
334+
def schema(self) -> Schema:
338335
return self._transaction.table_metadata.schema()
339336

340337
def spec(self, spec_id: int) -> PartitionSpec:
@@ -381,10 +378,10 @@ def _build_delete_files_partition_predicate(self) -> None:
381378
group = partition_to_overwrite.setdefault(data_file.spec_id, set())
382379
group.add(data_file.partition)
383380

384-
for spec_id, data_files in partition_to_overwrite.items():
381+
for spec_id, partition_records in partition_to_overwrite.items():
385382
self.delete_by_predicate(
386383
self._transaction._build_partition_predicate(
387-
partition_records=data_files, schema=self.schema(), spec=self.spec(spec_id)
384+
partition_records=partition_records, schema=self.schema(), spec=self.spec(spec_id)
388385
)
389386
)
390387

0 commit comments

Comments
 (0)