-
Notifications
You must be signed in to change notification settings - Fork 5.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
*: support create table with range type table partition. #6251
Conversation
First step to implement table partition.
@coocood We should merge this PR after the 2.0-GA release. |
@@ -846,3 +847,19 @@ func (n *TruncateTableStmt) Accept(v Visitor) (Node, bool) { | |||
n.Table = node.(*TableName) | |||
return v.Leave(n) | |||
} | |||
|
|||
// PartitionDefinition defines a single partition. | |||
type PartitionDefinition struct { |
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.
s/PartitionDefinition/RangePartitionDefinition/ ?
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 can hold other partition types.
type PartitionDefinition struct { | ||
ID int64 | ||
Name string | ||
LessThan []string |
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.
LessThan
is only used in range partition ?
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.
Yes
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.
so how do we define a hash or list or key partition ?
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 would be implemented later... @zz-jason
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 think we should implement a more extensible struct to define partition info.
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's compatible when we add new fields later.
LGTM |
ddl/ddl_api.go
Outdated
Expr: s.Partition.Expr.Text(), | ||
} | ||
if s.Partition.Expr != nil { | ||
var buf = bytes.NewBuffer([]byte{}) |
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.
var buf bytes.Buffer
ddl/ddl_api.go
Outdated
MaxValue: def.MaxValue, | ||
} | ||
for _, expr := range def.LessThan { | ||
var buf = bytes.NewBuffer([]byte{}) |
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.
ditto
/run-all-tests |
is := d.GetInformationSchema() | ||
schema, ok := is.SchemaByName(ident.Schema) | ||
if !ok { | ||
return infoschema.ErrDatabaseNotExists.GenByArgs(ident.Schema) | ||
} | ||
if is.TableExists(ident.Schema, ident.Name) { | ||
if s.IfNotExists { |
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.
Could you add a test to cover this logic?
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
The first step to implement table partition.