Fix hidden cloumn may disappeared (#4686)

* xx

* xx

* xx
This commit is contained in:
Zhengguo Yang
2020-09-30 10:01:49 +08:00
committed by GitHub
parent 0475aa9b93
commit 97dd634cdc
3 changed files with 15 additions and 4 deletions

View File

@ -517,7 +517,7 @@ public class MaterializedViewHandler extends AlterHandler {
boolean meetReplaceValue = false;
KeysType keysType = olapTable.getKeysType();
Map<String, Column> baseColumnNameToColumn = Maps.newHashMap();
for (Column column : olapTable.getSchemaByIndexId(baseIndexId)) {
for (Column column : olapTable.getSchemaByIndexId(baseIndexId, true)) {
baseColumnNameToColumn.put(column.getName(), column);
}
if (keysType.isAggregationFamily()) {
@ -555,6 +555,12 @@ public class MaterializedViewHandler extends AlterHandler {
throw new DdlException("Rollup should contains all keys if there is a REPLACE value");
}
}
if (KeysType.UNIQUE_KEYS == olapTable.getKeysType() && olapTable.hasDeleteSign()) {
rollupSchema.add(new Column(olapTable.getDeleteSignColumn()));
}
if (KeysType.UNIQUE_KEYS == olapTable.getKeysType() && olapTable.hasSequenceCol()) {
rollupSchema.add(new Column(olapTable.getSequenceCol()));
}
}
} else if (KeysType.DUP_KEYS == keysType) {
// supplement the duplicate key

View File

@ -582,7 +582,7 @@ public class SchemaChangeHandler extends AlterHandler {
// check if the new column already exist in base schema.
// do not support adding new column which already exist in base schema.
List<Column> baseSchema = olapTable.getBaseSchema();
List<Column> baseSchema = olapTable.getBaseSchema(true);
boolean found = false;
for (Column column : baseSchema) {
if (column.getName().equalsIgnoreCase(newColName)) {
@ -1381,7 +1381,7 @@ public class SchemaChangeHandler extends AlterHandler {
// index id -> index schema
Map<Long, LinkedList<Column>> indexSchemaMap = new HashMap<>();
for (Map.Entry<Long, List<Column>> entry : olapTable.getIndexIdToSchema().entrySet()) {
for (Map.Entry<Long, List<Column>> entry : olapTable.getIndexIdToSchema(true).entrySet()) {
indexSchemaMap.put(entry.getKey(), new LinkedList<>(entry.getValue()));
}
List<Index> newIndexes = olapTable.getCopiedIndexes();

View File

@ -514,9 +514,14 @@ public class OlapTable extends Table {
// schema
public Map<Long, List<Column>> getIndexIdToSchema() {
return getIndexIdToSchema(Util.showHiddenColumns());
}
// schema
public Map<Long, List<Column>> getIndexIdToSchema(boolean full) {
Map<Long, List<Column>> result = Maps.newHashMap();
for (Map.Entry<Long, MaterializedIndexMeta> entry : indexIdToMeta.entrySet()) {
result.put(entry.getKey(), entry.getValue().getSchema(Util.showHiddenColumns()));
result.put(entry.getKey(), entry.getValue().getSchema(full));
}
return result;
}