Skip to content

Commit

Permalink
[Fix](schema change) Fix can't do reorder column schema change for MO…
Browse files Browse the repository at this point in the history
…W table and duplicate key table (apache#37067)

## Proposed changes

1. set column's field `isAggregationTypeImplicit` correctly for mow
table and duplicate key table to let `SchemaChangeHandler::createJob`
can recognize that the schema change is a column reorder case.
2. remove useless test cases `test_schema_change_datev2_with_delete`,
`test_dup_keys_schema_change_datev2`. These two cases wanted to test
schema change from `datev1`/`datetimev1` to `datev2`/`datetimev2`. But
the default type of columns created as `date`/`datetime` are already
`datev2`/`datetimev2` now. Thest test cases should have met error
"Nothing is changed. please check your alter stmt." when doris enable
`datev2`/`datetimev2` by default but it didn't because
`isAggregationTypeImplicit` is wrongly set for duplicate table column.
  • Loading branch information
bobhan1 authored Jul 3, 2024
1 parent def48d5 commit 4984222
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 445 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ private boolean processModifyColumn(ModifyColumnClause alterClause, OlapTable ol
}
if (!modColumn.isKey()) {
if (olapTable.getEnableUniqueKeyMergeOnWrite()) {
modColumn.setAggregationType(AggregateType.NONE, false);
modColumn.setAggregationType(AggregateType.NONE, true);
} else {
modColumn.setAggregationType(AggregateType.REPLACE, true);
}
Expand Down Expand Up @@ -1387,6 +1387,14 @@ private void createJob(String rawSql, long dbId, OlapTable olapTable, Map<Long,
if (!alterColumn.equals(originSchema.get(i))) {
needAlterColumns.add(alterColumn);
hasColumnChange = true;
} else {
Column oriColumn = originSchema.get(i);
if ((oriColumn.getGeneratedColumnInfo() != null
|| alterColumn.getGeneratedColumnInfo() != null)
&& !oriColumn.getGeneratedColumnInfo().getExprSql()
.equals(alterColumn.getGeneratedColumnInfo().getExprSql())) {
throw new DdlException("Not supporting alter table modify generated columns.");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void validate(boolean isOlap, Set<String> keysSet, boolean isEnableMergeO
}

if (isOlap) {
if (!isKey && keysType.equals(KeysType.UNIQUE_KEYS)) {
if (!isKey && (keysType.equals(KeysType.UNIQUE_KEYS) || keysType.equals(KeysType.DUP_KEYS))) {
aggTypeImplicit = true;
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !dup --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343} {"a":1,"b":[1],"c":1.0}

-- !dup --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"a":1,"b":[1],"c":1.0} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343}
2 {"f1": "E", "f2": "F", "f3": 30, "f4": 484.3234} {"a":1,"b":[1],"c":1.0} \N

-- !mor --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343} {"a":1,"b":[1],"c":1.0}

-- !mor --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"a":1,"b":[1],"c":1.0} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343}
2 {"f1": "E", "f2": "F", "f3": 30, "f4": 484.3234} {"a":1,"b":[1],"c":1.0} \N

-- !mow --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343} {"a":1,"b":[1],"c":1.0}

-- !mow --
1 {"f1": "A", "f2": "B", "f3": 10, "f4": 3.14} {"a":1,"b":[1],"c":1.0} {"f1": "C", "f2": "D", "f3": 20, "f4": 8.343}
2 {"f1": "E", "f2": "F", "f3": 30, "f4": 484.3234} {"a":1,"b":[1],"c":1.0} \N

Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ suite("alter_column_test_generated_column") {
sql "alter table alter_column_gen_col modify column c double as (a+b) after e;"
exception "Not supporting alter table modify generated columns."
}
test {
sql "alter table alter_column_gen_col modify column c int as (a+b) after e;"
exception "Not supporting alter table modify generated columns."
}

// reorder column
qt_reorder "alter table alter_column_gen_col order by(a,c,b,d,e);"
Expand Down

This file was deleted.

Loading

0 comments on commit 4984222

Please sign in to comment.