rutb327 commented on code in PR #2305:
URL: https://github.com/apache/iceberg-python/pull/2305#discussion_r2283110191
##########
pyiceberg/table/update/schema.py:
##########
@@ -658,6 +658,14 @@ def _apply(self) -> Schema:
# Check the field-ids
new_schema = Schema(*struct.fields)
+ if self._transaction is not None:
+ from pyiceberg.partitioning import validate_partition_name
+
+ for spec in self._transaction.table_metadata.partition_specs:
+ for partition_field in spec.fields:
+ validate_partition_name(
+ partition_field.name, partition_field.transform,
partition_field.source_id, new_schema
+ )
Review Comment:
okay, I'll do the suggested changes
##########
pyiceberg/table/update/spec.py:
##########
@@ -174,16 +174,12 @@ def _commit(self) -> UpdatesAndRequirements:
return updates, requirements
def _apply(self) -> PartitionSpec:
- def _check_and_add_partition_name(schema: Schema, name: str,
source_id: int, partition_names: Set[str]) -> None:
- try:
- field = schema.find_field(name)
- except ValueError:
- field = None
-
- if source_id is not None and field is not None and field.field_id
!= source_id:
- raise ValueError(f"Cannot create identity partition from a
different field in the schema {name}")
- elif field is not None and source_id != field.field_id:
- raise ValueError(f"Cannot create partition from name that
exists in schema {name}")
+ def _check_and_add_partition_name(
+ schema: Schema, name: str, source_id: int, transform:
Transform[Any, Any], partition_names: Set[str]
+ ) -> None:
+ from pyiceberg.partitioning import validate_partition_name
+
+ validate_partition_name(name, transform, source_id, schema)
if not name:
Review Comment:
We can do that
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]