jonahgao commented on code in PR #15135: URL: https://github.com/apache/datafusion/pull/15135#discussion_r1995225073
########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -776,8 +777,32 @@ impl LogicalPlanBuilder { &missing_cols, is_distinct, )?; + + let mut sort_exprs = normalize_sorts(sorts, &plan)?; + if matches!(&plan, LogicalPlan::Union(_)) Review Comment: Since we stripped qualifiers, it should be reasonable that `order by t1.a` fails. I tested this behavior in PostgreSQL, and it works that way. ```sh psql=> select a from t1 union all select a from t2 order by t1.a; ERROR: missing FROM-clause entry for table "t1" LINE 1: select a from t1 union all select a from t2 order by t1.a; ^ psql=> select a from t1 union all select a from t2 order by a; a --- (0 rows) ``` Moreover, it seems like a bug to me if `order by not_exist_table.a` executes successfully. -- 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