twuebi commented on code in PR #567:
URL: https://github.com/apache/iceberg-go/pull/567#discussion_r2360057533
##########
table/sorting.go:
##########
@@ -137,6 +137,38 @@ type SortOrder struct {
Fields []SortField `json:"fields"`
}
+func (s *SortOrder) CheckCompatibility(schema *iceberg.Schema) error {
+ if s == nil {
+ return nil
+ }
+
+ for _, field := range s.Fields {
+ f, ok := schema.FindFieldByID(field.SourceID)
+ if !ok {
+ return fmt.Errorf("sort field with source id %d not
found in schema", field.SourceID)
+ }
+
+ if _, ok := f.Type.(iceberg.PrimitiveType); !ok {
+ return fmt.Errorf("cannot sort by non-primitive source
field: %s", f.Type.Type())
+ }
+ // TODO: rust has fallible ResultType for invalid transforms,
are we ok leaving them out?
+ // if field_transform.result_type(source_type).is_err() {
+ // return Err(Error::new(ErrorKind::Unexpected,
+ // format!(
+ // "Invalid source type
{source_type} for transform {field_transform}"
+ // ),
+ // ));
+ // }
+ // ---------
+ // typ, err :=field.Transform.ResultType(f.Type)
+ // if err != nil {
+ // return fmt.Errorf("invalid source type %s for transform
%s: %w", f.Type.Type(), field.Transform, err)
+ // }
Review Comment:
IIRC, this check exists somewhere in iceberg-go too, probably closer to the
transaction, will look into 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]