devanbenz commented on code in PR #12466:
URL: https://github.com/apache/datafusion/pull/12466#discussion_r1768853375


##########
datafusion/sql/src/statement.rs:
##########
@@ -1136,14 +1136,29 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
         schema: &DFSchemaRef,
         planner_context: &mut PlannerContext,
     ) -> Result<Vec<Vec<SortExpr>>> {
-        // Ask user to provide a schema if schema is empty.
+        let mut all_results = vec![];
         if !order_exprs.is_empty() && schema.fields().is_empty() {
-            return plan_err!(
-                "Provide a schema before specifying the order while creating a 
table."
-            );
+            let mut results = vec![];
+            for expr in order_exprs {
+                for ordered_expr in expr {
+                    let order_expr = ordered_expr.expr.to_owned();
+                    let order_expr = self.sql_expr_to_logical_expr(
+                        order_expr,
+                        schema,
+                        planner_context,
+                    )?;
+                    let nulls_first = ordered_expr.nulls_first.unwrap_or(true);

Review Comment:
   For /datafusion/sql/src/expr/order_by.rs#L40-L39 I was thinking about 
modifying it so it could build an order_by without a schema. I think that since 
this is the only area (maybe) where this would be used maybe its not worth 
modifying a code path like that though. 



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