-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
parser: support empty target list in SELECT #116835
Conversation
a4a47eb
to
dcd209f
Compare
Nice! I like this. (I vote that you do
I don't think there is a way to preserve this exact contextual help rule, since
|
Interestingly, Raphael arrived at the same solution to this issue and also didn't see a way to not remove the contextual help. I'll play around with some rules to preserve the contextual help. |
dcd209f
to
0335b00
Compare
Added these suggestions which reverted 2 of the tests to the previous state. However, I'm not sure whether these new rules are actually worth it - like the grammar now looks even dirtier, and this help in a few cases might not be that helpful. These new rules are also quite arbitrary - we could probably come up with a dozen of others, so why stop here? So I'm leaning towards not adding these new error rules, and the question is whether we're ok removing the contextual error help in order to support this syntax. It seems worth it to me. Thoughts? |
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.
lgtm! i think losing the help output for SELECT
(with no other tokens) is fine
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.
Will the \h SELECT
command in the cli still work?
Reviewable status:
complete! 0 of 0 LGTMs obtained
This commit adds support for parsing empty target list for SELECT stmts (i.e. queries of the form `SELECT;`, `SELECT ALL FROM t;`, `SELECT FROM t;` where the projection column list is omitted). Apparently, some tools like hasura use it to get the row count. This is achieved by making `target_list` optional. However, the caveat is that the new parsing rule runs into a shift/reduce conflict with `SELECT error` rule (since now both options can match empty string after `SELECT` AFAICT). I tried adjusting the precedence of the newly adjusted rule to resolve this conflict but didn't succeed (Raphael tried doing the same with the same result). Release note (sql change): CockroachDB now supports parsing queries like `SELECT FROM t` that only produce the row count and do not output any columns.
0335b00
to
da147cf
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.
\h SELECT
still works, yes. @michae2 are you ok with this change without any extra rules for partial error support too?
Reviewable status:
complete! 0 of 0 LGTMs obtained
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.
LGTM!
TFTRs! bors r+ |
This PR was included in a batch that timed out, it will be automatically retried |
bors r+ |
Already running a review |
This PR was included in a batch that timed out, it will be automatically retried |
Build succeeded: |
This started passing after cockroachdb#116835 was merged. Release note: None
117516: roachtest: mark asyncpg test as passing r=rafiss a=rafiss This started passing after #116835 was merged. fixes #117379 Release note: None 117580: workload: a few fixes for schema change watchdog r=rafiss a=rafiss The log message it created on failure did not produce readable output. Also, the watchdog could get confused if a query completed and the session ended up in an idle state. fixes #117533 Release note: None Co-authored-by: Rafi Shamim <[email protected]>
This started passing after cockroachdb#116835 was merged. Release note: None
This commit adds support for parsing empty target list for SELECT stmts (i.e. queries of the form
SELECT;
,SELECT ALL FROM t;
,SELECT FROM t;
where the projection column list is omitted). Apparently, some tools like hasura use it to get the row count.This is achieved by making
target_list
optional. However, the caveat is that the new parsing rule runs into a shift/reduce conflict withSELECT error
rule (since now both options can match empty string afterSELECT
AFAICT). I tried adjusting the precedence of the newly adjusted rule to resolve this conflict but didn't succeed (Raphael tried doing the same with the same result).Fixes: #83255.
Release note (sql change): CockroachDB now supports parsing queries like
SELECT FROM t
that only produce the row count and do not output any columns.