-
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: support scalar expressions (& placeholders) for alter range ... relocate #73807
Conversation
88161fe
to
22f0af4
Compare
you could try use |
can you explain how that works? Or maybe link to a doc that explains?
unfortunately the interval syntax is in d_expr (the narrowest one)
yeah I thought about that, and if there's no solution via %prec, I'll put the choice to a vote on the KV team: either |
Best I can find is https://www.ibm.com/docs/en/zos/2.3.0?topic=section-precedence-in-grammar-rules, I only have a vague understanding of it cargo culting from pg |
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.
If we support placeholders now, it would be good to have some tests for that. I can't find many existing tests for RELOCATE, maybe we can add some similar to TestSplitAt
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani and @lunevalex)
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
Thanks to the goyacc source code, I found out that it uses a super old algorithm that only supports real token names in |
22f0af4
to
4ce7404
Compare
For future reference, I troubleshooted my yacc problem with the following mini-grammar: %token RELOCATE FROM TO FOR SELECT DAY TO MINUTE
%left INTERVAL_SHORT
%left TO
%%
top:
RELOCATE FROM a TO a FOR SELECT
a: b
b: DAY %prec INTERVAL_SHORT
| DAY TO MINUTE %prec TO |
@@ -73,10 +73,10 @@ statement error operation is unsupported in multi-tenancy mode | |||
ALTER RANGE RELOCATE LEASE TO 2 FOR SELECT range_id from crdb_internal.ranges where table_name = 'kv' | |||
|
|||
statement error operation is unsupported in multi-tenancy mode | |||
ALTER RANGE 1 RELOCATE FROM 1 TO 2 | |||
ALTER RANGE 1 RELOCATE TO 2 FROM 1 |
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.
revert?
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.
Good call. Done.
For @RaduBerinde:
Good point. I modified the existing test in |
4ce7404
to
2a162b8
Compare
2a162b8
to
f5e30c7
Compare
I have extended the PR with a 2nd commit that also adds placeholder support in the first position, so that this PR closes the linked issue entirely. Please take another look. |
249d818
to
d84d380
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.
lgtm, some small test failure that look like simple rewrites
d84d380
to
3ddfc4f
Compare
TFYRs! bors r=lunevalex,otan |
bors r- |
Canceled. |
bors r=lunevalex,otan |
This commit makes it possible to use arbitrary scalar expressions (incl subqueries, placeholders etc) in the FROM/TO clauses of ALTER RANGE ... RELOCATE statements. For example: ``` ALTER RANGE 123 RELOCATE FROM $1 TO $2 ALTER RANGE 123 RELOCATE FROM $1 TO $1+10 ``` Release note (sql change): The experimental ALTER RANGE...RELOCATE syntax now accepts arbitrary scalar expressions as the source and target store IDs. Release note (sql change): The output of `EXPLAIN ALTER RANGE ... RELOCATE` now includes the source and target store IDs.
This commit makes it possible to use arbitrary scalar expressions (incl subqueries, placeholders etc) in the RANGE clause of ALTER RANGE ... RELOCATE statements. For example: ``` ALTER RANGE $1 RELOCATE FROM 3 TO 4 ``` Release note (sql change): The experimental ALTER RANGE...RELOCATE syntax now accepts arbitrary scalar expressions as the range ID when the FOR clause is not used.
Release note (sql change): The output of `EXPLAIN ALTER RANGE ... RELOCATE` now includes which replicas are subject to the relocation.
7d190dc
to
77f169d
Compare
Canceled. |
bors r=lunevalex,otan |
Build succeeded: |
Opt changes LGTM. |
Fixes #73315.
See the individual commits for details.