-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Create UNION plan node with correct schema #14380
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
Comments
Hello @findepi! I'd be happy to work on this. I believe it's as simple as shifting union schema coercion from the analyzer to logical plan building. However, since wildcard expansion happens later on, we wouldn't want to attempt coercing the plan inputs. Which makes me wonder - is there benefit to producing a plan that has a correct schema but may have non-coerced input plans? 🤔 |
You have good point about the wildcards
i don't think there is |
We need to rely on the We might need to perform union coercion twice: once in the builder, and once in |
I also think it's necessary to move the Perhaps @goldmedal have some thoughts on it. |
+1 on moving
Hmm, my immediate thought here is that if we cannot guarantee correctly coerced inputs during the first pass, then it's probably not worth attempting to coerce in the builder at all. But, I could be missing something! |
The original discussion about wildcard expansion is #11639 (comment). It's used to delay the wildcard expansion to decrease the cost when facing huge column numbers (#11639 (comment)).
Indeed. I have no idea how to avoid this 🤔. Maybe moving wildcard expansion back to the builder is the only choice (?
I'm not pretty sure if Or maybe we can allow the customized behavior for the wildcard planning, just like the original reason of #11639 |
Since
Using ExprPlanner makes sense to me. |
I think most cases can be correctly coerced during the first pass; it is a best-effort behavior. |
I see. I think we can revert the change #11681 first. Also cc @jayzhan211
👍 |
Doing coercion twice doesn't make sense to me. Should we move |
I appreciate the conciseness of representing all columns of a table with a wildcard. Of course, there is |
I also thought about that, but some users do not want the casts introduced by |
We can make it optional or even customizable |
Computing a schema for a wildcard differs from expanding the actual expressions that match the wildcard |
This is very broad statement. |
I think their logic is basically the same, otherwise there would be issues similar to #14102. Another potential issue is that in exprlist_to_fields, we don't handle replace items, but ExpandWildcardRule does. |
Is your feature request related to a problem or challenge?
When building a query plan
union()
behavior doesn't type-coerce the expressions and it takes the left node's schema.This creates an invalid plan which later needs to be fixed. It would be better to create a valid plan from the start.
Note: #14356 moves the code around, but doesn't change the behavior. See @alamb's #14356 (comment)
Describe the solution you'd like
Create correctly coerced plan if possible
Describe alternatives you've considered
Keep creating incorrect plan. Rely on some later logic to fix it some time later.
Additional context
try_new
forLogicalPlan::Join
Join
and others #14363 talks about similar problem, but for JOIN. It's better to be able to create a valid plan.The text was updated successfully, but these errors were encountered: