tustvold commented on code in PR #8021:
URL: https://github.com/apache/arrow-datafusion/pull/8021#discussion_r1392544054


##########
datafusion/core/src/datasource/mod.rs:
##########
@@ -58,29 +57,33 @@ fn create_ordering(
     let mut all_sort_orders = vec![];
 
     for exprs in sort_order {
-        // Construct PhsyicalSortExpr objects from Expr objects:
-        let sort_exprs = exprs
-            .iter()
-            .map(|expr| {
-                if let Expr::Sort(Sort { expr, asc, nulls_first }) = expr {
-                    if let Expr::Column(col) = expr.as_ref() {
-                        let expr = expressions::col(&col.name, schema)?;
-                        Ok(PhysicalSortExpr {
-                            expr,
-                            options: SortOptions {
-                                descending: !asc,
-                                nulls_first: *nulls_first,
-                            },
-                        })
-                    } else {
-                        plan_err!("Expected single column references in 
output_ordering, got {expr}")
+        // Construct PhysicalSortExpr objects from Expr objects:
+        let mut sort_exprs = vec![];
+        for expr in exprs {
+            match expr {
+                Expr::Sort(sort) => match sort.expr.as_ref() {
+                    Expr::Column(col) => match expressions::col(&col.name, 
schema) {
+                        Ok(expr) => {
+                            sort_exprs.push(PhysicalSortExpr {
+                                expr,
+                                options: SortOptions {
+                                    descending: !sort.asc,
+                                    nulls_first: sort.nulls_first,
+                                },
+                            });
+                        }
+                        // Cannot find expression in the projected_schema, 
stop iterating

Review Comment:
   This is necessary as the sort key may reference columns not found in the 
projected schema.
   
   This change matches get_projected_output_ordering



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

Reply via email to