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

parser, ddl: correct the job type of 'REORGANIZE PARTITION' #42490

Merged
merged 1 commit into from
Mar 22, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion parser/model/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ func (job *Job) NotStarted() bool {
// MayNeedReorg indicates that this job may need to reorganize the data.
func (job *Job) MayNeedReorg() bool {
switch job.Type {
case ActionAddIndex, ActionAddPrimaryKey:
case ActionAddIndex, ActionAddPrimaryKey, ActionReorganizePartition:
return true
case ActionModifyColumn:
if len(job.CtxVars) > 0 {
Expand Down
31 changes: 31 additions & 0 deletions parser/model/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,34 @@ func TestBackfillMetaCodec(t *testing.T) {
bmRet.Decode(bmBytes)
require.Equal(t, bm, bmRet)
}

func TestMayNeedReorg(t *testing.T) {
//TODO(bb7133): add more test cases for different ActionType.
reorgJobTypes := []model.ActionType{
model.ActionReorganizePartition,
model.ActionAddIndex,
model.ActionAddPrimaryKey,
}
generalJobTypes := []model.ActionType{
model.ActionCreateTable,
model.ActionDropTable,
}
job := &model.Job{
ID: 100,
Type: model.ActionCreateTable,
SchemaID: 101,
TableID: 102,
SchemaName: "test",
TableName: "t",
State: model.JobStateDone,
MultiSchemaInfo: nil,
}
for _, jobType := range reorgJobTypes {
job.Type = jobType
require.True(t, job.MayNeedReorg())
}
for _, jobType := range generalJobTypes {
job.Type = jobType
require.False(t, job.MayNeedReorg())
}
}