Implement Unparser for UNION ALL
#10603
Merged
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.
Which issue does this PR close?
It doesn't close this issue, but is part of the work for #9494
Rationale for this change
Adds support for turning LogicalPlans that have
Union
LogicalPlans (without distinct, so onlyUNION ALL
, notUNION
) into SQL strings.It should be relatively easy now to support bare
UNION
by first inspecting theDistinct
node - but I ran out of time on this PR.What changes are included in this PR?
Splits
select_to_sql
into two parts:select_to_sql_statement
andselect_to_sql_expr
. LIMIT and ORDER BY are only valid in a statement context, whereas all other plans can appear in a SELECT expression. This allows the parsing for UNION ALL to turn each of its inputs into a SELECT expression, and still respect the LIMIT/ORDER BY at the statement level.Are these changes tested?
Yes, added two tests to the
roundtrip_sql
integration test.Are there any user-facing changes?
This expands the valid plans that can be unparsed back to SQL strings, and is backwards compatible.