Omit NULLS FIRST/LAST when unparsing ORDER BY clauses for MySQL#10625
Omit NULLS FIRST/LAST when unparsing ORDER BY clauses for MySQL#10625alamb merged 5 commits intoapache:mainfrom
Conversation
|
cc @backkem @devinjdangelo to take a look |
backkem
left a comment
There was a problem hiding this comment.
LGTM, we'll have to remember to upstream this to the SQLParser package.
alamb
left a comment
There was a problem hiding this comment.
Thanks @phillipleblanc and @backkem
I wonder if we should update the comments in Dialect so that we can upstream the trait once we have some more experience with what features are needed in DataFusion 🤔
I can see the argument both for upstreaming and for keeping them separate. Although the argument for upstreaming is stronger imo. The argument for upstreaming is: We want a single The argument for keeping them separate is: By putting in logic to I'll update the comment for edit: I realized after posting this, it does make sense to throw an error when parsing a MySQL dialect if the string contains edit 2: Here is the sqlparser-rs PR: apache/datafusion-sqlparser-rs#1284 edit 3: I closed that PR, see below discussion |
|
Also, I think it's the idea to move the entire unparser to the SQLParser package eventually. |
I think this may be hard, as the Unparser relies in |
|
I closed the upstream So for now I'll just remove the comment on the Unparser Dialect linking to the now closed PR and we can revisit later. |
|
Thanks @phillipleblanc and @backkem |
…he#10625) * Omit `NULLS FIRST/LAST` when deparsing ORDER BY clauses for MySQL * Add test and fix sort_to_sql * Fix link for cargo doc * Remove reference to sqlparser-rs PR
…he#10625) * Omit `NULLS FIRST/LAST` when deparsing ORDER BY clauses for MySQL * Add test and fix sort_to_sql * Fix link for cargo doc * Remove reference to sqlparser-rs PR
Which issue does this PR close?
Closes #10624
Rationale for this change
When unparsing LogicalPlans back to SQL statements for the MySQL dialect, any plan that includes a
Sortnode will produce a SQL statement that looks like:The
NULLS LASTcauses issues when run against a MySQL server, as it doesn't recognize that syntax.What changes are included in this PR?
Adds a new function to the Unparser Dialect called
supports_nulls_first_in_sortwhich is defaulttrue, but set tofalsefor the MySQL dialect. And in the relevant unparsing code, we set the AST node to None.Are these changes tested?
Yes, added a new test to cover dialect-specific behavior.
Are there any user-facing changes?
No breaking changes.