sql: new built-in generator pg_get_keywords#19127
Conversation
justinj
left a comment
There was a problem hiding this comment.
LGTM (with two comments), I wonder why PG chose to make this a generator function rather than a system table.
| -9223372036854775807 | ||
|
|
||
| # pg_get_keywords for compatibility (#10291) | ||
| query TTT |
There was a problem hiding this comment.
Probably worth doing a colnames for this test?
| } | ||
| } | ||
| columns := make(sqlbase.ResultColumns, len(tType.Cols)) | ||
| for i := range columns { |
There was a problem hiding this comment.
I just realized PG lets you specify the label for a single-column generator:
justin=# select * from unnest(array[1,2,3]) a;
a
---
1
2
3
(3 rows)
is that something we can easily support?
9549f26 to
897ba35
Compare
|
Review status: 0 of 11 files reviewed at latest revision, 2 unresolved discussions. pkg/sql/generator.go, line 62 at r4 (raw file): Previously, justinj (Justin Jaffray) wrote…
Awwww bad pg, bad. This is a weird mechanism. I'll investigate. However it's separate, it wasn't supported before this PR anyways. pkg/sql/logictest/testdata/logic_test/generators, line 247 at r4 (raw file): Previously, justinj (Justin Jaffray) wrote…
Yes indeed. Done. Comments from Reviewable |
|
Added a commit with the pg behavior, PTAL |
803ec33 to
1d69e26
Compare
|
Reviewed 2 of 2 files at r1, 4 of 4 files at r2, 6 of 6 files at r5, 4 of 4 files at r6, 2 of 2 files at r7. pkg/sql/data_source.go, line 491 at r7 (raw file):
pull out these two conditions into variables pkg/sql/parser/generator_builtins.go, line 237 at r2 (raw file):
Consider pulling this into a static variable too. pkg/sql/parser/generator_builtins.go, line 220 at r5 (raw file):
nit: efficiency doesn't matter here so just set the capacity and append to get rid of pkg/sql/parser/sql.y, line 5617 at r1 (raw file):
This is creating a zero-length Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. Comments from Reviewable |
This patch makes the built-in definitions decide themselves the labels of the result columns. This in turn simplifies logical planning.
|
Review status: all files reviewed at latest revision, 6 unresolved discussions, some commit checks failed. pkg/sql/data_source.go, line 491 at r7 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/sql/parser/generator_builtins.go, line 237 at r2 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Can't do, it's dependent on pkg/sql/parser/generator_builtins.go, line 220 at r5 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. pkg/sql/parser/sql.y, line 5617 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. Comments from Reviewable |
1d69e26 to
4061df8
Compare
4061df8 to
c9e887c
Compare
Requested in #10291 (comment).
This PR includes some other useful refactors and cleanups.