CTTY commented on code in PR #1978:
URL: https://github.com/apache/iceberg-rust/pull/1978#discussion_r2658495686
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -506,6 +506,19 @@ impl TableMetadata {
/// If the default sort order is unsorted but the sort order is not
present, add it
fn try_normalize_sort_order(&mut self) -> Result<()> {
+ // Validate that sort order ID 0 (reserved for unsorted) has no fields
+ if let Some(sort_order) =
self.sort_order_by_id(SortOrder::UNSORTED_ORDER_ID)
+ && !sort_order.fields.is_empty()
+ {
+ return Err(Error::new(
+ ErrorKind::DataInvalid,
Review Comment:
This should be `ErrorKind::Unexpected` according to
https://github.com/apache/iceberg-rust/blob/main/crates/iceberg/src/spec/sort.rs#L157
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -506,6 +506,19 @@ impl TableMetadata {
/// If the default sort order is unsorted but the sort order is not
present, add it
fn try_normalize_sort_order(&mut self) -> Result<()> {
+ // Validate that sort order ID 0 (reserved for unsorted) has no fields
+ if let Some(sort_order) =
self.sort_order_by_id(SortOrder::UNSORTED_ORDER_ID)
+ && !sort_order.fields.is_empty()
+ {
+ return Err(Error::new(
Review Comment:
+1 I think failing here is better and more consistent to Java's behavior
--
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]