[fix](schema_change) remove shadow prefix of schema for tablesink (#18822)
LSC updates tablet's schema in writing. Be optimized adding columns via linked schema change and it distinguishes adding by comparing column name. e.g. if new column's name is not found in old schema, then it is a newly-add column. When a table is under schema-changing, it adds __doris_shadow_ prefix in name of columns in shadow index. Then writes during schema-changing would bring schema with __doris_shadow_ to be. If schema change request arrives at be after writes, then be do it as a add-column schema change due to __doris_shadow_ is not in base tablet.
This commit is contained in:
@ -698,6 +698,7 @@ public class SchemaChangeHandler extends AlterHandler {
|
||||
*/
|
||||
modColumn.setName(SHADOW_NAME_PREFIX + modColumn.getName());
|
||||
}
|
||||
LOG.info("modify column {} ", modColumn);
|
||||
return lightSchemaChange;
|
||||
}
|
||||
|
||||
|
||||
@ -270,6 +270,10 @@ public class Column implements Writable, GsonPostProcessable {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getNonShadowName() {
|
||||
return removeNamePrefix(name);
|
||||
}
|
||||
|
||||
public String getNameWithoutMvPrefix() {
|
||||
return CreateMaterializedViewStmt.mvColumnBreaker(name);
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ public class OlapTableSink extends DataSink {
|
||||
List<String> columns = Lists.newArrayList();
|
||||
List<TColumn> columnsDesc = Lists.newArrayList();
|
||||
List<TOlapTableIndex> indexDesc = Lists.newArrayList();
|
||||
columns.addAll(indexMeta.getSchema().stream().map(Column::getName).collect(Collectors.toList()));
|
||||
columns.addAll(indexMeta.getSchema().stream().map(Column::getNonShadowName).collect(Collectors.toList()));
|
||||
for (Column column : indexMeta.getSchema()) {
|
||||
TColumn tColumn = column.toThrift();
|
||||
column.setIndexFlag(tColumn, table);
|
||||
|
||||
Reference in New Issue
Block a user