Handle DuckDB's ORDER BY ALL properly - #483
Open
eddietejeda wants to merge 2 commits into
Open
eddietejeda wants to merge 2 commits into
eddietejeda wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ORDER BY ALLis already listed as a known failure category intests/analyze_failures.rs, so not completely unexpected.DuckDB parses ALL as a column called
all, which has two consequences:allis inPOSTGRES_RESERVED, andDUCKDB_RESERVEDis a copy of that set, so the output is:In DuckDB,
"ALL"refers to a column named "ALL," so the query no longer runs.Second, every other target uses the same
ORDER BY "ALL", and none accept it.What this does
Removes
allfromDUCKDB_RESERVED, so DuckDB output keeps the keyword bare.When the source is DuckDB and the target isn't, a lone unquoted
ALLin ORDER BY becomesORDER BY 1, 2, ...over the select list. Every dialect accepts that. Direction and null order are preserved, and it works inside subqueries. DuckDB puts NULLs last even in DESC, so the expansion spells outNULLS LAST, whereas the target would default differently.If the select list is
*, we don't know how many columns there are, so it's reported as an unsupported translation instead of emitting SQL that can't run.A quoted
"all"in the source is a real column and is left alone.Tests
tests/duckdb_order_by_all.rs: the DuckDB round trip, expansion for three targets, direction and null order, subqueries, the*error, and the quoted-column case.