sql: Support tuple column access and tuple stars#26628
sql: Support tuple column access and tuple stars#26628craig[bot] merged 2 commits intocockroachdb:masterfrom
Conversation
17a34fa to
fc9e675
Compare
daafc18 to
f87b423
Compare
|
This is looking really good! I added a few remarks. Also, for the optimizer stuff, it would be good to get someone from the optimizer team to take a look. Reviewed 1 of 1 files at r1, 17 of 17 files at r2, 7 of 7 files at r3. pkg/sql/opt_decompose.go, line 1519 at r2 (raw file):
Please tell me there is a unit test for this. Cause it surely needs one badly. I'm not a fan of the slicing up of the typs here. Why not just keep two index variables around instead of this fanciness? pkg/sql/opt_decompose.go, line 1577 at r2 (raw file):
This too, needs a unit test too. pkg/sql/logictest/testdata/logic_test/srfs, line 782 at r3 (raw file):
Is this needed? pkg/sql/logictest/testdata/logic_test/srfs, line 795 at r3 (raw file):
Can you add subtests for these new tests? pkg/sql/logictest/testdata/logic_test/srfs, line 838 at r3 (raw file):
Leftover tabs pkg/sql/logictest/testdata/logic_test/srfs, line 895 at r3 (raw file):
Was this change intentional? pkg/sql/logictest/testdata/logic_test/tuple, line 763 at r3 (raw file):
Move this declaration of t down to where it is used. pkg/sql/logictest/testdata/logic_test/tuple, line 768 at r3 (raw file):
extra empty line pkg/sql/opt/exec/execbuilder/scalar_builder.go, line 125 at r2 (raw file):
Move this into the return statement directly? pkg/sql/opt/memo/extract.go, line 48 at r2 (raw file):
This one can go in the return statement too. pkg/sql/sem/tree/datum.go, line 2484 at r2 (raw file):
Should this be a pointer? Is this not adding a ttuple to every dtuple? Also, why call this typ? How about ttuple so there is no ambiguity? pkg/sql/sem/tree/eval.go, line 3486 at r1 (raw file):
This is worded awkwardly. The returned bool indicates that the NULL should be propagated. pkg/sql/sem/tree/expr.go, line 1509 at r3 (raw file):
Add a note that Star may be mutated during type check. pkg/sql/sem/tree/type_check_test.go, line 257 at r3 (raw file):
Probably a good idea to do as my leftover todo says. :) Comments from Reviewable |
|
Review status: pkg/sql/opt_decompose.go, line 1519 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
The tests are in But I reverted these changes. They are not needed because labels in IN comparisons never matter. pkg/sql/opt_decompose.go, line 1577 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
ditto pkg/sql/opt/exec/execbuilder/scalar_builder.go, line 125 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
I find it harder to read. pkg/sql/opt/memo/extract.go, line 48 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
ditto pkg/sql/sem/tree/datum.go, line 2484 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
The name The use by value instead of pointer is because of #26680. pkg/sql/sem/tree/eval.go, line 3486 at r1 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Done. Comments from Reviewable |
|
pkg/sql/opt_decompose.go, line 1519 at r2 (raw file): Previously, knz (kena) wrote…
Ah, cool. But if you did keep it in, you needed to augment those tests with labels. Comments from Reviewable |
|
pkg/sql/opt/exec/execbuilder/scalar_builder.go, line 125 at r2 (raw file): Previously, knz (kena) wrote…
ok Comments from Reviewable |
|
Reviewed 22 of 22 files at r4, 17 of 17 files at r5, 7 of 7 files at r6. Comments from Reviewable |
|
opt stuff LGTM Reviewed 7 of 17 files at r5. Comments from Reviewable |
|
Review status: pkg/sql/logictest/testdata/logic_test/srfs, line 782 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
What does the word "this" refer to in your question? pkg/sql/logictest/testdata/logic_test/srfs, line 795 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Done. pkg/sql/logictest/testdata/logic_test/srfs, line 838 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Done. pkg/sql/logictest/testdata/logic_test/srfs, line 895 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Yes because there is no index in the virtual table information_schema.columns. pkg/sql/logictest/testdata/logic_test/tuple, line 763 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Done. pkg/sql/logictest/testdata/logic_test/tuple, line 768 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Done. pkg/sql/sem/tree/expr.go, line 1509 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Changed to a separate type TupleStar. pkg/sql/sem/tree/type_check_test.go, line 257 at r3 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Can you detail what you mean? pkg/sql/opt_decompose.go, line 1519 at r2 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
I agree. Comments from Reviewable |
|
Review status: pkg/sql/sem/tree/type_check_test.go, line 257 at r3 (raw file): Previously, knz (kena) wrote…
Removed comment as per offline discussion. Comments from Reviewable |
|
Probably should have opt team do one last pass for the new changes. Reviewed 20 of 20 files at r7, 4 of 4 files at r8. pkg/sql/targets.go, line 70 at r7 (raw file):
This is even worse than going over the line limit. How about pkg/sql/logictest/testdata/logic_test/srfs, line 782 at r3 (raw file): Previously, knz (kena) wrote…
I think it was for table j. Looks like it is needed. So just ignore this. Probably the code was hidden by reviewable when reviewing. Comments from Reviewable |
|
@rytaft: I have extended/reworked the opt star expansion. PTAL. Review status: pkg/sql/targets.go, line 70 at r7 (raw file): Previously, BramGruneir (Bram Gruneir) wrote…
Good idea. Done. Comments from Reviewable |
899aaf2 to
59fa893
Compare
|
Reviewed 3 of 3 files at r9. Comments from Reviewable |
|
Reviewed 6 of 20 files at r7, 1 of 3 files at r9. pkg/sql/opt/optbuilder/project.go, line 82 at r9 (raw file):
I'd change this to pkg/sql/opt/optbuilder/scope.go, line 533 at r9 (raw file):
TupleStar -> TupleStars (or change are -> is) pkg/sql/opt/optbuilder/util.go, line 37 at r9 (raw file):
Update comment to include TupleStar. pkg/sql/opt/optbuilder/util.go, line 52 at r9 (raw file):
When is the type pkg/sql/opt/optbuilder/util.go, line 98 at r9 (raw file):
Update comment to include TupleStar Comments from Reviewable |
|
Review status: pkg/sql/opt/optbuilder/project.go, line 82 at r9 (raw file): Previously, rytaft wrote…
Done. pkg/sql/opt/optbuilder/scope.go, line 533 at r9 (raw file): Previously, rytaft wrote…
Done. pkg/sql/opt/optbuilder/util.go, line 37 at r9 (raw file): Previously, rytaft wrote…
Done. pkg/sql/opt/optbuilder/util.go, line 52 at r9 (raw file): Previously, rytaft wrote…
Added example. pkg/sql/opt/optbuilder/util.go, line 98 at r9 (raw file): Previously, rytaft wrote…
Done. Comments from Reviewable |
|
thanks for the reviews! bors r+ |
Build failed |
All the Datums generated must be distinct in memory, because different generated rows can be stored in memory and compared against each other. Release note: None
This work is yet another step towards cockroachdb#16971. The labeled tuples introduced in cockroachdb#25283 can now be accessed using their labels or using a star, e.g. `(E).*`. Release note (sql change): Labeled tuples can now be accessed using their labels (e.g. `SELECT (x).word FROM (SELECT pg_expand_keywords() AS x)` or a star (e.g. `SELECT (x).* FROM (SELECT pg_expand_keywords() AS x)`). Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
|
Had to fix #26720 too. Retrying. bors r+ |
26628: sql: Support tuple column access and tuple stars r=knz a=knz First commits from #26621. Completes the fix to #24866 by re-activating disabled tests. This work is yet another step towards #16971. It would actually fix #16971 if it were not for #26627, #26624 and #26629. This work is yet another step towards #16971. The labeled tuples introduced in #25283 can now be accessed using their labels or using a star, e.g. `(E).*`. Release note (sql change): Labeled tuples can now be accessed using their labels (e.g. `SELECT (x).word FROM (SELECT pg_expand_keywords() AS x)` or a star (e.g. `SELECT (x).* FROM (SELECT pg_expand_keywords() AS x)`). Fixes #26720. Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com> Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
Build succeeded |
First commits from #26621.
Completes the fix to #24866 by re-activating disabled tests.
This work is yet another step towards #16971. It would actually fix #16971 if it were not for #26627, #26624 and #26629.
This work is yet another step towards #16971.
The labeled tuples introduced in #25283 can now be accessed using
their labels or using a star, e.g.
(E).*.Release note (sql change): Labeled tuples can now be accessed using
their labels (e.g.
SELECT (x).word FROM (SELECT pg_expand_keywords() AS x)or a star (e.g.SELECT (x).* FROM (SELECT pg_expand_keywords() AS x)).Fixes #26720.