alamb commented on code in PR #9202:
URL: https://github.com/apache/arrow-datafusion/pull/9202#discussion_r1486296187


##########
datafusion/sql/src/expr/function.rs:
##########
@@ -149,18 +149,37 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             )?;
 
             let func_deps = schema.functional_dependencies();
-            // Find whether ties are possible in the given ordering:
-            let is_ordering_strict = order_by.iter().any(|orderby_expr| {
+            // Find whether ties are possible in the given ordering
+            let is_ordering_strict = order_by.iter().find_map(|orderby_expr| {
                 if let Expr::Sort(sort_expr) = orderby_expr {
                     if let Expr::Column(col) = sort_expr.expr.as_ref() {
-                        let idx = schema.index_of_column(col).unwrap();
-                        return func_deps.iter().any(|dep| {
+                        let idx_result = schema.index_of_column(col);
+
+                        // Propagate the error to the caller and return it 
immediately
+                        let idx = idx_result

Review Comment:
   I think the `ok()` function call here discards the error. 
   
   I think changing 
   ```rust
                           let idx = schema.index_of_column(col).unwrap();
   ```
   
   To 
   ```rust
                           let idx = schema.index_of_column(col).ok()?;
   ```
   
   accomplishes the same thing (and your test still passes)



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