-
Notifications
You must be signed in to change notification settings - Fork 490
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
Support add/drop attributes for table or partition #1271
Conversation
what is the difference between this and PLACEMENT POLICY? |
ast/ddl.go
Outdated
@@ -2648,6 +2651,19 @@ func (n *AlterTableSpec) Restore(ctx *format.RestoreCtx) error { | |||
return errors.Annotatef(err, "An error occurred while restore AlterTableSpec.PlacementSpecs[%d]", i) | |||
} | |||
} | |||
case AlterTableAlterPartitionAttributes: | |||
if len(n.PartitionNames) != 1 { | |||
return errors.Errorf("Maybe partition options are combined.") |
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.
This error message indicates the number of partion names is over 1, what about zero?
We are going to add some attributes to a table/partition to solve some specified problems. e.g., |
143e065
to
6ebf0e8
Compare
@rleungx We may also need to consider the removal syntax for attributes. Anyway, it would be better if there is a detailed design document. |
a8bb32c
to
3332b2d
Compare
3332b2d
to
ea7714f
Compare
PTAL @djshow832 @xhebox, thanks. |
How about using |
ea7714f
to
4d99cd9
Compare
parser.y
Outdated
$$ = &ast.AlterTableSpec{ | ||
Tp: ast.AlterTablePartition, | ||
Partition: $1.(*ast.PartitionOptions), | ||
if alterTableSpec, ok := $1.(*ast.AlterTableSpec); ok { |
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.
I suggest adding a new term ATTRIBUTES : "ATTRIBUTES" "=" stringLit | "DEFAULT"
, which will return the attributes spec, to reuse and write less code.
And the change here is not elegant for me. It is strange if PartitionOpt
did not return PartitionOptions
.
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
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
@nolouch: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
{"ALTER TABLE t ATTRIBUTES='str1,str2'", true, "ALTER TABLE `t` ATTRIBUTES='str1,str2'"}, | ||
{"ALTER TABLE t ATTRIBUTES=DEFAULT", true, "ALTER TABLE `t` ATTRIBUTES=DEFAULT"}, | ||
{"ALTER TABLE t ATTRIBUTES=default", true, "ALTER TABLE `t` ATTRIBUTES=DEFAULT"}, | ||
{"ALTER TABLE t ATTRIBUTES=DeFaUlT", true, "ALTER TABLE `t` ATTRIBUTES=DEFAULT"}, |
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.
BTW, Default meaning empty or may have some default attributes?
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.
It will reset the attributes. And since we don't have the default attributes for now, it can be regarded as empty.
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
c731350
to
ad6dc6b
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.
Rest LGTM
parser.y
Outdated
"ATTRIBUTES" "=" "DEFAULT" | ||
{ | ||
$$ = &ast.AttributesSpec{Default: true} | ||
} | ||
| "ATTRIBUTES" "=" stringLit | ||
{ | ||
$$ = &ast.AttributesSpec{Default: false, Attributes: $3} | ||
} | ||
|
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.
As I recall, =
is optional in all table options in MySQL.
@@ -2783,6 +2783,20 @@ func (s *testParserSuite) TestDDL(c *C) { | |||
{"ALTER TABLE t ALTER PLACEMENT POLICY CONSTRAINTS='str' ROLE=leader REPLICAS=1", true, "ALTER TABLE `t` ALTER PLACEMENT POLICY CONSTRAINTS='str' ROLE=LEADER REPLICAS=1"}, | |||
{"ALTER TABLE t ADD PLACEMENT POLICY CONSTRAINTS='str1' ROLE=leader REPLICAS=1, ADD PLACEMENT POLICY CONSTRAINTS='str2' ROLE=leader REPLICAS=1", true, "ALTER TABLE `t` ADD PLACEMENT POLICY CONSTRAINTS='str1' ROLE=LEADER REPLICAS=1, ADD PLACEMENT POLICY CONSTRAINTS='str2' ROLE=LEADER REPLICAS=1"}, | |||
|
|||
// alter attributes | |||
{"ALTER TABLE t ATTRIBUTES='str'", true, "ALTER TABLE `t` ATTRIBUTES='str'"}, | |||
{"ALTER TABLE t ATTRIBUTES='str1,str2'", true, "ALTER TABLE `t` ATTRIBUTES='str1,str2'"}, |
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.
How about double quotation marks, like "str1, str2"?
Signed-off-by: Ryan Leung <rleungx@gmail.com>
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 8938372
|
What problem does this PR solve?
It's used for the region label feature. Closes #1288.
What is changed and how it works?
This PR is going to support
to change the attributes of a table or a partition.
And use the following syntax to reset all attributes for a table or a partition:
Check List
Tests
Related changes