sql: support a limited subset of correlated SRFs#26503
sql: support a limited subset of correlated SRFs#26503craig[bot] merged 4 commits intocockroachdb:masterfrom
Conversation
Release note: None
Release note: None
Release note: None
7baf986 to
01bf327
Compare
0e2ee99 to
da68eba
Compare
|
But probably a good idea to have another set of eyes on this too. Someone with a deeper history of planning. Reviewed 1 of 1 files at r1, 1 of 1 files at r2, 1 of 1 files at r3, 6 of 6 files at r4. pkg/sql/opt_needed.go, line 114 at r4 (raw file):
could this be an else if? pkg/sql/logictest/testdata/logic_test/srfs, line 864 at r4 (raw file):
Are you missing an empty line at the end? Comments from Reviewable |
This patch extends the "project set" operator previously implemented so that it can evaluate expressions using references to the rows of the source. This makes it able to evaluate SRFs correlated with the data source. This patch then extends the transform of SRFs in render position to use the new functionality. With this patch, a query like this now runs properly: `SELECT unnest(indkey) from pg_index` Although the execution logic is now able to run arbitrary correlated SRFs, the planning for `ROWS FROM` is not yet adjusted to use this functionality and therefore SRFs listed in `ROWS FROM` cannot be correlated yet. Release note (sql change): CockroachDB now can evaluate set-generating functions with arguments that refer to the FROM clause. In particular this makes it possible to use `json_each()`, `json_object_keys()` etc over JSON columns.
|
Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. pkg/sql/opt_needed.go, line 114 at r4 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
No but it can certainly be simplified. Done. pkg/sql/logictest/testdata/logic_test/srfs, line 864 at r4 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Yep, thanks for noticing. Comments from Reviewable |
|
Reviewed 1 of 1 files at r1, 1 of 1 files at r3, 2 of 6 files at r4, 2 of 2 files at r5. Comments from Reviewable |
|
Thank you! bors r+ |
26503: sql: support a limited subset of correlated SRFs r=knz a=knz Next-to-last step before solving #16971. This patch extends the "project set" operator previously implemented so that it can evaluate expressions using references to the rows of the source. This makes it able to evaluate SRFs correlated with the data source. This patch then extends the transform of SRFs in render position to use the new functionality. With this patch, a query like this now runs properly: `SELECT unnest(indkey) from pg_index` Although the execution logic is now able to run arbitrary correlated SRFs, the planning for `ROWS FROM` is not yet adjusted to use this functionality and therefore SRFs listed in `ROWS FROM` cannot be correlated yet. Release note (sql change): CockroachDB now can evaluate set-generating functions with arguments that refer to the FROM clause. **In particular this makes it possible to use `json_each()`, `json_object_keys()` etc over JSON columns.** cc @solongordon cc @justinj Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
Build succeeded |
Next-to-last step before solving #16971.
This patch extends the "project set" operator previously implemented
so that it can evaluate expressions using references to the rows of
the source. This makes it able to evaluate SRFs correlated with the
data source.
This patch then extends the transform of SRFs in render position
to use the new functionality. With this patch, a query like this now
runs properly:
SELECT unnest(indkey) from pg_indexAlthough the execution logic is now able to run arbitrary correlated
SRFs, the planning for
ROWS FROMis not yet adjusted to use thisfunctionality and therefore SRFs listed in
ROWS FROMcannot becorrelated yet.
Release note (sql change): CockroachDB now can evaluate set-generating
functions with arguments that refer to the FROM clause. In particular
this makes it possible to use
json_each(),json_object_keys()etcover JSON columns.
cc @solongordon
cc @justinj