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

*: support create table with range type table partition. #6251

Merged
merged 8 commits into from
Apr 12, 2018

Conversation

coocood
Copy link
Member

@coocood coocood commented Apr 10, 2018

The first step to implement table partition.

First step to implement table partition.
@coocood coocood added the DDL label Apr 10, 2018
@shenli
Copy link
Member

shenli commented Apr 10, 2018

@coocood We should merge this PR after the 2.0-GA release.

@shenli shenli added this to the 2.1 milestone Apr 10, 2018
@@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/PartitionDefinition/RangePartitionDefinition/ ?

Copy link
Member Author

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
Copy link
Member

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 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Member

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 ?

Copy link
Contributor

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

Copy link
Member

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.

Copy link
Member Author

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.

@tiancaiamao
Copy link
Contributor

LGTM

ddl/ddl_api.go Outdated
Expr: s.Partition.Expr.Text(),
}
if s.Partition.Expr != nil {
var buf = bytes.NewBuffer([]byte{})
Copy link
Contributor

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{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@tiancaiamao tiancaiamao added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 10, 2018
@zz-jason
Copy link
Member

/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 {
Copy link
Contributor

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?

Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@coocood coocood merged commit 533fac1 into pingcap:master Apr 12, 2018
@coocood coocood deleted the partition-skeleton branch April 12, 2018 13:56
@ciscoxll ciscoxll added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 27, 2018
@you06 you06 added the sig/sql-infra SIG: SQL Infra label Mar 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/sql-infra SIG: SQL Infra status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants