Skip to content

Commit e6ce4a2

Browse files
authored
[fix](meta) fix Unknown column 'mva_SUM__CAST` (#41285)
## Proposed changes cherry pick from #41283
1 parent bf3d424 commit e6ce4a2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java

+19
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.doris.catalog;
1919

2020
import org.apache.doris.analysis.Analyzer;
21+
import org.apache.doris.analysis.CastExpr;
2122
import org.apache.doris.analysis.CreateMaterializedViewStmt;
2223
import org.apache.doris.analysis.Expr;
2324
import org.apache.doris.analysis.SlotRef;
@@ -214,6 +215,24 @@ private void setColumnsDefineExpr(Map<String, Expr> columnNameToDefineExpr) thro
214215
}
215216
}
216217

218+
boolean isCastSlot =
219+
entry.getValue() instanceof CastExpr && entry.getValue().getChild(0) instanceof SlotRef;
220+
221+
// Compatibility code for older versions of mv
222+
// old version:
223+
// goods_number -> mva_SUM__CAST(`goods_number` AS BIGINT)
224+
// new version:
225+
// goods_number -> mva_SUM__CAST(`goods_number` AS bigint)
226+
if (isCastSlot && !match) {
227+
for (Column column : schema) {
228+
if (column.getName().equalsIgnoreCase(entry.getKey())) {
229+
column.setDefineExpr(entry.getValue());
230+
match = true;
231+
break;
232+
}
233+
}
234+
}
235+
217236
if (!match) {
218237
// Compatibility code for older versions of mv
219238
// store_id -> mv_store_id

0 commit comments

Comments
 (0)