-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge?
Given a SQL like
WITH vals AS
(
SELECT 1 x, 'a' y UNION ALL
SELECT 1 x, 'b' y UNION ALL
SELECT 2 x, 'a' y UNION ALL
SELECT 2 x, 'c' y
)
SELECT x, y
FROM valsThe unoptimized plan is
Projection: vals.x, vals.y
SubqueryAlias: vals
Union
Union
Union
Projection: Int64(1) AS x, Utf8("a") AS y
EmptyRelation
Projection: Int64(1) AS x, Utf8("b") AS y
EmptyRelation
Projection: Int64(2) AS x, Utf8("a") AS y
EmptyRelation
Projection: Int64(2) AS x, Utf8("c") AS y
EmptyRelation
It's fine for the unparser. However, after EliminateNestedUnion optimization rule, the nested union will be flatten to one union like
Projection: vals.x, vals.y
SubqueryAlias: vals
Union
Projection: Int64(1) AS x, Utf8("a") AS y
EmptyRelation
Projection: Int64(1) AS x, Utf8("b") AS y
EmptyRelation
Projection: Int64(2) AS x, Utf8("a") AS y
EmptyRelation
Projection: Int64(2) AS x, Utf8("c") AS y
EmptyRelation
If we tried to unparse this plan, we will get the error message:
Error: This feature is not implemented: UNION ALL expected 2 inputs, but found 4
Describe the solution you'd like
Currently, the unpaser only supports unparsing an union with 2 input
datafusion/datafusion/sql/src/unparser/plan.rs
Lines 630 to 635 in 172e557
| if union.inputs.len() != 2 { | |
| return not_impl_err!( | |
| "UNION ALL expected 2 inputs, but found {}", | |
| union.inputs.len() | |
| ); | |
| } |
We should support unparsing the union with more 2 inputs for the Unparser.
Describe alternatives you've considered
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request