-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Omit NULLS FIRST/LAST when unparsing ORDER BY clauses for MySQL #10625
Omit NULLS FIRST/LAST when unparsing ORDER BY clauses for MySQL #10625
Conversation
cc @backkem @devinjdangelo to take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, we'll have to remember to upstream this to the SQLParser package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Sort
node will produce a SQL statement that looks like:The
NULLS LAST
causes 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_sort
which is defaulttrue
, but set tofalse
for 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.