kevalds51 commented on code in PR #27794:
URL: https://github.com/apache/datafusion/pull/27794#discussion_r4744854564


##########
datafusion/datasource-parquet/src/metadata.rs:
##########
@@ -1259,8 +1247,12 @@ fn sorting_columns_to_physical_exprs(
 
     sorting_columns
         .iter()
-        .filter_map(|sc| {
-            let parquet_column = parquet_schema.column(sc.column_idx as usize);
+        .map_while(|sc| {
+            let leaf_index = usize::try_from(sc.column_idx).ok()?;
+            let parquet_column = parquet_schema.columns().get(leaf_index)?;
+            if parquet_column.path().parts().len() != 1 {

Review Comment:
   This rejects nested paths, but a top-level `repeated` primitive (legacy list 
encoding, e.g. `repeated int32 x` directly under the root) also has a one-part 
path. It's read back as a `List` field, so we'd declare the file ordered by a 
list column, which the leaf ordering doesn't imply (empty lists, for example). 
Checking the repetition level closes that:
   
   ```suggestion
               if parquet_column.path().parts().len() != 1
                   || parquet_column.max_rep_level() != 0
               {
                   return None;
               }
   ```
   
   The old code accepted this too, so a follow-up is fine if you'd rather keep 
this PR tight.



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