-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-48557][SQL] Support scalar subquery with group-by on column equal to constant #46902
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
Conversation
| val correlated = AttributeSet(splitConjunctivePredicates(cond) | ||
| .filter(containsOuter) // TODO: can remove this line to allow e.g. where x = 1 group by x | ||
| .filter( | ||
| SQLConf.get.getConf(SQLConf.SCALAR_SUBQUERY_ALLOW_GROUP_BY_COLUMN_EQUAL_TO_CONSTANT) |
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.
I'm not sure we need this config and this restriction is newly added. It's OK to relax this un-released restriction.
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.
Yea I think we can remove this config.
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.
Actually the restriction isn't new - it was there before for many years - so we are in fact adding newly supported query shapes.
So I added the config as per the usual flag any surface area change. Can remove it if we don't need it though.
| val correlated = AttributeSet(splitConjunctivePredicates(cond) | ||
| .filter(containsOuter) // TODO: can remove this line to allow e.g. where x = 1 group by x | ||
| .filter( | ||
| SQLConf.get.getConf(SQLConf.SCALAR_SUBQUERY_ALLOW_GROUP_BY_COLUMN_EQUAL_TO_CONSTANT) |
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.
Yea I think we can remove this config.
|
thanks, merging to master! |
What changes were proposed in this pull request?
We can enable scalar subqueries that have
group by aif there's a predicatea = 1, because these predicates guarantee the group-by produces at most one row. (This builds on top of #46839 and enables shapes there were unsupported prior to that PR as well.)Why are the changes needed?
Support valid subquery shapes.
Does this PR introduce any user-facing change?
Yes, support subquery shapes.
How was this patch tested?
Unit tests
Was this patch authored or co-authored using generative AI tooling?
No