From e3e249c5842dd9d5ef1b9955e29f2e2061a5cd3e Mon Sep 17 00:00:00 2001 From: xy720 <22125576+xy720@users.noreply.github.com> Date: Fri, 17 Nov 2023 21:24:53 +0800 Subject: [PATCH] [Bug](SchemeChange) Loading tasks during alter job cause modify column failed (#26975) When a table is doing schema-change, it adds _doris_shadow prefix in name of modified columns in shadow index. The writes during schema-change will generate rowset schema with _doris_shadow prefix in BE. If the alter task arrives at be after the write request, it will use the rowset schema with max version which has the _doris_shadow prefix. And an error will be thrown as below: a shadow column is encountered __doris_shadow_p_retailprice [INTERNAL_ERROR]failed due to operate on shadow column This commit will disable shadow prefix in rowset meta schema. --- .../main/java/org/apache/doris/planner/OlapTableSink.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java index fa3b4abee9..e2cc67d992 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/OlapTableSink.java @@ -17,6 +17,7 @@ package org.apache.doris.planner; +import org.apache.doris.alter.SchemaChangeHandler; import org.apache.doris.analysis.Analyzer; import org.apache.doris.analysis.Expr; import org.apache.doris.analysis.SlotDescriptor; @@ -252,6 +253,12 @@ public class OlapTableSink extends DataSink { columns.addAll(indexMeta.getSchema().stream().map(Column::getNonShadowName).collect(Collectors.toList())); for (Column column : indexMeta.getSchema()) { TColumn tColumn = column.toThrift(); + // When schema change is doing, some modified column has prefix in name. Columns here + // is for the schema in rowset meta, which should be no column with shadow prefix. + // So we should remove the shadow prefix here. + if (column.getName().startsWith(SchemaChangeHandler.SHADOW_NAME_PREFIX)) { + tColumn.setColumnName(column.getNonShadowName()); + } column.setIndexFlag(tColumn, table); columnsDesc.add(tColumn); }