gabeiglio commented on code in PR #2410:
URL: https://github.com/apache/iceberg-python/pull/2410#discussion_r2732037334


##########
pyiceberg/table/sorting.py:
##########
@@ -169,6 +170,16 @@ def __repr__(self) -> str:
         fields = f"{', '.join(repr(column) for column in self.fields)}, " if 
self.fields else ""
         return f"SortOrder({fields}order_id={self.order_id})"
 
+    def check_compatible(self, schema: Schema) -> None:
+        for field in self.fields:
+            source_field = schema._lazy_id_to_field.get(field.source_id)
+            if source_field is None:
+                raise ValidationError(f"Cannot find source column for sort 
field: {field}")
+            if not source_field.field_type.is_primitive:
+                raise ValidationError(f"Cannot sort by non-primitive source 
field: {source_field}")
+            if not field.transform.can_transform(source_field.field_type):
+                raise ValidationError(f"Invalid source type 
{source_field.field_type} for transform: {field.transform}")

Review Comment:
   You are right, in a big enough schema this would make it hard to debug, will 
add



-- 
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]

Reply via email to