Skip to content

Conversation

@jchen5
Copy link
Contributor

@jchen5 jchen5 commented Jun 6, 2024

What changes were proposed in this pull request?

We can enable scalar subqueries that have group by a if there's a predicate a = 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

@github-actions github-actions bot added the SQL label Jun 6, 2024
@jchen5
Copy link
Contributor Author

jchen5 commented Jun 6, 2024

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)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@jchen5 jchen5 Jun 15, 2024

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)
Copy link
Contributor

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.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 90d302a Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants