goldmedal commented on PR #12994: URL: https://github.com/apache/datafusion/pull/12994#issuecomment-2425671715
> > This gets rewritten in the `GenericDialect` to: > > ``` > SELECT ta.j1_id FROM (SELECT ta.j1_id FROM j1 AS ta) > ``` > It's valid for DataFusion ``` > create table j1(j1_id int); 0 row(s) fetched. Elapsed 0.085 seconds. > SELECT ta.j1_id FROM (SELECT ta.j1_id FROM j1 AS ta); +-------+ | j1_id | +-------+ +-------+ 0 row(s) fetched. Elapsed 0.042 seconds. ``` Generally, `GenericDialect` fits the DataFusion syntax. This behavior makes sense to me. > Which is invalid, because the subquery is un-aliased. I tested it in DuckDB to confirm: > > ``` > D SELECT ta.j1_id FROM (SELECT ta.j1_id FROM j1 ta); > Binder Error: Referenced table "ta" not found! > Candidate tables: "unnamed_subquery" > LINE 1: SELECT ta.j1_id FROM (SELECT ta.j1_id FROM j1 ... > ``` > > Let's merge my PR, and I can raise a new issue for this other bug @goldmedal ? How about `MySQLDialect`? It enables `requires_derived_table_alias`. Which would be the result? ``` SELECT ta.j1_id FROM (SELECT ta.j1_id FROM j1 ta) derived_projection ``` or ``` SELECT j1_id FROM (SELECT ta.j1_id FROM j1 ta) `derived_projection` ``` If it's the first one, I think it's an issue because it isn't valid. We can file an issue for it. If it's the second one, I think the user can customize the `dialect::requires_derived_table_alias` for the DuckDB syntax purpose. -- 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]
