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


##########
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:
   I think this should be 
   ```suggestion
                       let nulls_first = 
ordered_expr.nulls_first.unwrap_or(!asc);
   ```
   
   Perhaps there is some way to refactor / reuse the code in 
https://github.com/apache/datafusion/blob/94d178ebe9674669b32ecd7896b5597f49e90791/datafusion/sql/src/expr/order_by.rs#L40-L39
 to avoid repeition



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to