Skip to content
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

parse more partition options in ALTER TABLE statements #394

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4248,6 +4248,90 @@ var (
"\tcol varchar(20) not null\n" +
"),,",
},

// partition options
{
input: "alter table t partition by range (store_id) (\n" +
"partition p0 values less than (6),\n" +
"partition p1 values less than (11),\n" +
"partition p2 values less than (16),\n" +
"partition p3 values less than (21)\n" +
")",
output: "alter table t",
},
{
input: "alter table t partition by hash ('values')",
output: "alter table t",
},
{
input: "alter table t partition by hash (col)",
output: "alter table t",
},
{
input: "alter table t partition by linear hash (col)",
output: "alter table t",
},
{
input: "alter table t partition by KEY (col)",
output: "alter table t",
},
{
input: "alter table t partition by KEY ALGORITHM = 7 (col)",
output: "alter table t",
},
{
input: "alter table t partition by linear KEY ALGORITHM = 7 (col)",
output: "alter table t",
},
{
input: "alter table t partition by RANGE (col)",
output: "alter table t",
},
{
input: "alter table t partition by RANGE (i + j)",
output: "alter table t",
},
{
input: "alter table t partition by RANGE (month(i))",
output: "alter table t",
},
{
input: "alter table t partition by RANGE (concat(i))",
output: "alter table t",
},
{
input: "alter table t partition by RANGE COLUMNS (c1, c2, c3)",
output: "alter table t",
},
{
input: "alter table t partition by LIST (col)",
output: "alter table t",
},
{
input: "alter table t partition by LIST (i + j)",
output: "alter table t",
},
{
input: "alter table t partition by LIST (month(i))",
output: "alter table t",
},
{
input: "alter table t partition by LIST (concat(i))",
output: "alter table t",
},
{
input: "alter table t partition by LIST COLUMNS (c1, c2, c3)",
output: "alter table t",
},
{
input: "alter table t partition by linear hash (a) partitions 20",
output: "alter table t",
},
{
input: "alter table t partition by linear hash (a) partitions 10 subpartition by linear hash (b) subpartitions 20",
output: "alter table t",
},

{
input: "table t",
output: "select * from t",
Expand Down Expand Up @@ -7404,6 +7488,7 @@ func TestCreateTable(t *testing.T) {
"\ti int\n" +
") partition by linear hash (a) partitions 10 subpartition by linear hash (b) subpartitions 20",
},

{
input: "create table t (\n" +
"\ti int\n)" +
Expand Down
Loading