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


##########
datafusion/datasource-parquet/src/metadata.rs:
##########
@@ -1332,6 +1324,86 @@ mod tests {
         Ok(())
     }
 
+    /// Leaves: payload.a, payload.b, b, id
+    fn schema_with_struct() -> Schema {
+        Schema::new(vec![
+            Field::new(
+                "payload",
+                DataType::Struct(Fields::from(vec![
+                    Field::new("a", DataType::Int32, true),
+                    Field::new("b", DataType::Int32, true),
+                ])),
+                true,
+            ),
+            Field::new("b", DataType::Int32, true),
+            Field::new("id", DataType::Int32, true),
+        ])
+    }
+
+    fn sorting_column(column_idx: i32) -> SortingColumn {
+        SortingColumn {
+            column_idx,
+            descending: false,
+            nulls_first: true,
+        }
+    }
+
+    #[test]
+    fn test_lex_ordering_to_sorting_columns_uses_leaf_indices() -> Result<()> {
+        let schema = schema_with_struct();

Review Comment:
   Could you add cases that cover more layouts than a two-field struct?
   - a `List` before the key: one leaf, so no shift. Checks that 
`root_to_first_leaf` handles a single-leaf nested root.
   - a 3-field struct before the key: a shift of 2, not 1.
   - a nested key as the *first* expression: should return `vec![]`, which 
`create_writer_physical_plan` then turns into `None`.
   - a struct plus a hive partition column, so `input_schema` and 
`writer_schema` differ at the same time as the leaf shift.



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