-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: support array-flatten subqueries within UDFs #98879
Conversation
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.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @DrewKimball)
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.
Reviewed 9 of 9 files at r1, all commit messages.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @mgartner)
pkg/sql/opt/norm/rules/scalar.opt
line 389 at r1 (raw file):
# and correlated ones only over the types that array_agg supports. # # Note that optbuilder should have already verified that if the input is
Since you're at it, I think we can remove this bit since #35710 is fixed. Same for the check in optbuilder/scalar.go
line 156.
pkg/sql/opt/exec/execbuilder/testdata/subquery
line 566 at r1 (raw file):
spans: FULL SCAN # Case where the a correlated subquery contains an uncorrelated array-flatten
[nit] the a
-> a
a6d69ad
to
a8a3b75
Compare
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.
Reviewable status: complete! 2 of 0 LGTMs obtained (waiting on @DrewKimball)
pkg/sql/opt/norm/rules/scalar.opt
line 389 at r1 (raw file):
Previously, DrewKimball (Drew Kimball) wrote…
Since you're at it, I think we can remove this bit since #35710 is fixed. Same for the check in
optbuilder/scalar.go
line 156.
Done.
pkg/sql/opt/exec/execbuilder/testdata/subquery
line 566 at r1 (raw file):
Previously, DrewKimball (Drew Kimball) wrote…
[nit]
the a
->a
Done.
bors r+ |
Build failed (retrying...): |
Build failed (retrying...): |
Build failed: |
Array-flatten subqueries (e.g., `ARRAY(SELECT a FROM t)`) are now supported within UDFs. They are now converted to a normal subquery with a ScalarGroupBy if they exist within a UDF, even if they are uncorrelated. This allows them to be executed without any changes to the execbuilder or the evaluation logic of `tree.Routine`. Fixes cockroachdb#98738 Release note: None
a8a3b75
to
99169e8
Compare
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 2 stale) (waiting on @DrewKimball)
pkg/sql/opt/norm/rules/scalar.opt
line 389 at r1 (raw file):
Previously, mgartner (Marcus Gartner) wrote…
Done.
This caused some test failures so I've reverted. I believe the check is still necessary.
Code quote:
# Note that optbuilder should have already verified that if the input is
# correlated, then we can array_agg over the input type. Also note that the
# Max1Row operator we introduce is guaranteed to be eliminated as
# MakeArrayAggForFlatten will return a ScalarGroupBy.
bors r+ |
Build failed (retrying...): |
Build failed (retrying...): |
Build succeeded: |
Array-flatten subqueries (e.g.,
ARRAY(SELECT a FROM t)
) are nowsupported within UDFs. They are now converted to a normal subquery with
a ScalarGroupBy if they exist within a UDF, even if they are
uncorrelated. This allows them to be executed without any changes to the
execbuilder or the evaluation logic of
tree.Routine
.Fixes #98738
Release note: None