Skip to content

Commit 2df6c84

Browse files
authored
[fix](meta) fix Unknown column 'mva_SUM__CAST` (#41284)
cherry pick from master #41283
1 parent 2fbad5d commit 2df6c84

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;
@@ -202,6 +203,24 @@ private void setColumnsDefineExpr(Map<String, Expr> columnNameToDefineExpr) thro
202203
}
203204
}
204205

206+
boolean isCastSlot =
207+
entry.getValue() instanceof CastExpr && entry.getValue().getChild(0) instanceof SlotRef;
208+
209+
// Compatibility code for older versions of mv
210+
// old version:
211+
// goods_number -> mva_SUM__CAST(`goods_number` AS BIGINT)
212+
// new version:
213+
// goods_number -> mva_SUM__CAST(`goods_number` AS bigint)
214+
if (isCastSlot && !match) {
215+
for (Column column : schema) {
216+
if (column.getName().equalsIgnoreCase(entry.getKey())) {
217+
column.setDefineExpr(entry.getValue());
218+
match = true;
219+
break;
220+
}
221+
}
222+
}
223+
205224
if (!match) {
206225
// Compatibility code for older versions of mv
207226
// store_id -> mv_store_id

0 commit comments

Comments
 (0)