[BUG] fix bug for schema schange (#6839)
This commit has an error: #6791 when you only change the order of column, error will apear.
This commit is contained in:
@ -1221,7 +1221,7 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
for (Column alterColumn : alterSchema) {
|
||||
if (alterColumn.nameEquals(partitionCol.getName(), true)) {
|
||||
// 2.1 partition column cannot be modified
|
||||
if (needAlterColumns.contains(alterColumn)) {
|
||||
if (needAlterColumns.contains(alterColumn) && !alterColumn.equals(partitionCol)) {
|
||||
throw new DdlException("Can not modify partition column["
|
||||
+ partitionCol.getName() + "]. index["
|
||||
+ olapTable.getIndexNameById(alterIndexId) + "]");
|
||||
@ -1250,7 +1250,7 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
for (Column alterColumn : alterSchema) {
|
||||
if (alterColumn.nameEquals(distributionCol.getName(), true)) {
|
||||
// 3.1 distribution column cannot be modified
|
||||
if (needAlterColumns.contains(alterColumn)) {
|
||||
if (needAlterColumns.contains(alterColumn) && !alterColumn.equals(distributionCol)) {
|
||||
throw new DdlException("Can not modify distribution column["
|
||||
+ distributionCol.getName() + "]. index["
|
||||
+ olapTable.getIndexNameById(alterIndexId) + "]");
|
||||
|
||||
@ -704,6 +704,26 @@ public class AlterTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeOrder() throws Exception {
|
||||
createTable("CREATE TABLE test.change_order\n" +
|
||||
"(\n" +
|
||||
" k1 date,\n" +
|
||||
" k2 int,\n" +
|
||||
" v1 int sum\n" +
|
||||
")\n" +
|
||||
"PARTITION BY RANGE(k1)\n" +
|
||||
"(\n" +
|
||||
" PARTITION p1 values less than('2020-02-01'),\n" +
|
||||
" PARTITION p2 values less than('2020-03-01')\n" +
|
||||
")\n" +
|
||||
"DISTRIBUTED BY HASH(k2) BUCKETS 3\n" +
|
||||
"PROPERTIES('replication_num' = '1');");
|
||||
|
||||
String changeOrderStmt = "ALTER TABLE test.change_order ORDER BY (k2, k1, v1);;";
|
||||
alterTable(changeOrderStmt, false);
|
||||
}
|
||||
|
||||
private boolean checkAllTabletsExists(List<Long> tabletIds) {
|
||||
TabletInvertedIndex invertedIndex = Catalog.getCurrentCatalog().getTabletInvertedIndex();
|
||||
for (long tabletId : tabletIds) {
|
||||
|
||||
Reference in New Issue
Block a user