Skip to content

Commit

Permalink
parser, ddl: correct the job type of 'REORGANIZE PARTITION' (#42490) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Mar 23, 2023
1 parent 624aa88 commit 69ae178
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
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())
}
}

0 comments on commit 69ae178

Please sign in to comment.