Skip to content

Commit

Permalink
parser, ddl: correct the job type of 'REORGANIZE PARTITION'
Browse files Browse the repository at this point in the history
Signed-off-by: bb7133 <bb7133@gmail.com>
  • Loading branch information
bb7133 authored and ti-chi-bot committed Mar 22, 2023
1 parent 42957c5 commit 54b84cb
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 54b84cb

Please sign in to comment.