-
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/parser: Support ANY/SOME/ALL array operators #12102
sql/parser: Support ANY/SOME/ALL array operators #12102
Conversation
Nice! I wonder if this could become cleaner by adding a new type for the quantifier operators. See comments below. Review status: 0 of 12 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. pkg/sql/parser/eval.go, line 1447 at r1 (raw file):
I think a brief header comment on this function could be really helpful, e.g. pkg/sql/parser/eval.go, line 1449 at r1 (raw file):
Will this function horribly break if subOp isn't any/some/all? Should we check that condition? Alternatively, would it make any sense to break any/some/all out into their own new type? They aren't really ComparisonOperators after all - they're quantifiers. pkg/sql/parser/eval.go, line 1452 at r1 (raw file):
Perhaps this argument could be deleted? This function has all the information it needs to decide the value of pkg/sql/parser/eval.go, line 1457 at r1 (raw file):
Does this cast need an error check? pkg/sql/parser/expr.go, line 351 at r1 (raw file):
Hmm, so SubOperator is Any/Some/All? I don't think I would have any idea what this indicates if I was reading this code for the first time. Can you think of a better name? Perhaps Quantifier could be suitable, as in the existential/universal quantifiers in math which these operators correspond to. If you disagree, I think a less terse comment is warranted. Comments from Reviewable |
Thanks for the review! I'm still working on cleaning some of this up, but as a general comment,
Clearly, this needs improved documentation so that its not confusing. Review status: 0 of 12 files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. Comments from Reviewable |
Reviewed 11 of 12 files at r1. pkg/sql/parser/eval.go, line 1449 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Agreed, these should have their own type. Granted they may not be enums but they cannot be anything else than any/some/all right? pkg/sql/parser/sql.y, line 3639 at r1 (raw file):
Once #12111 is merged, I would favor a single rule here instead of two:
This way we can then write pkg/sql/parser/type_check_test.go, line 124 at r1 (raw file):
I'm not fond of this limitation, I think we should support ANY/SOME on tuples right away not just arrays. Comments from Reviewable |
Thanks for the review @knz. Still cleaning some of this up but addresses a few questions, Review status: 11 of 12 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. pkg/sql/parser/eval.go, line 1449 at r1 (raw file): Previously, knz (kena) wrote…
@knz did you happen to see my comment above? any/some/all are not subOps, they're the primary operators. pkg/sql/parser/sql.y, line 3639 at r1 (raw file): Previously, knz (kena) wrote…
I'd be in favor of that because it would allow us to address the issue is brought up in pkg/sql/parser/type_check_test.go, line 124 at r1 (raw file): Previously, knz (kena) wrote…
ANY/SOME is a strictly Postgres extension, and they only support arrays. Is it worth extending their extension even further? Comments from Reviewable |
Review status: 11 of 12 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. pkg/sql/parser/eval.go, line 1449 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
I think I did not understand it the first time round. Now it's clearer, thanks. Comments from Reviewable |
Any chance of getting this in early next week? |
943a5e5
to
a3bf07e
Compare
After a bit of cleanup, a rebase, and some trial-and-error to convince myself that there isn't a nicer way to do the sub-operation stuff, this is ready for a full review now. Review status: 1 of 12 files reviewed at latest revision, 7 unresolved discussions, some commit checks pending. pkg/sql/parser/eval.go, line 1447 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
Done. pkg/sql/parser/eval.go, line 1457 at r1 (raw file): Previously, jordanlewis (Jordan Lewis) wrote…
It doesn't because type checking and normalization will assure that only a pkg/sql/parser/sql.y, line 3639 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
Done. Changed a lot of tests for this too. Comments from Reviewable |
Excellent, this looks much cleaner now. Just a nit about one of the main error messages. Reviewed 11 of 11 files at r2. pkg/sql/parser/sql.y, line 3717 at r2 (raw file):
I don't like this message because 1) it's not really informative and 2) it doesn't tell the user what to do to fix the problem. What about
pkg/sql/parser/type_check_test.go, line 124 at r1 (raw file): Previously, nvanbenschoten (Nathan VanBenschoten) wrote…
I think they also work on subqueries. But I may be wrong. Comments from Reviewable |
a3bf07e
to
e61b7bf
Compare
TFTR! Review status: 9 of 12 files reviewed at latest revision, 6 unresolved discussions. pkg/sql/parser/sql.y, line 3717 at r2 (raw file): Previously, knz (kena) wrote…
This was ripped directly from Postgres, but I like your phrasing better. Done. pkg/sql/parser/type_check_test.go, line 124 at r1 (raw file): Previously, knz (kena) wrote…
SGTM :) Comments from Reviewable |
LGTM I think you need to rebase as your test is hitting a bug in |
Closes cockroachdb#10519. This change adds support for the `ANY`, `SOME`, and `ALL` array operators, which are needed for Hibernate support. See https://www.postgresql.org/docs/9.6/static/functions-comparisons.html for details.
e61b7bf
to
eaf3787
Compare
Closes #10519.
This change adds support for the
ANY
,SOME
, andALL
arrayoperators, which are needed for Hibernate support. See
https://www.postgresql.org/docs/9.6/static/functions-comparisons.html
for details.
This is a WIP because I think some of the type checking code can be
cleaned up before merging.
This change is