[fix](meta) fix Unknown column 'mva_SUM__CAST` (#41285)

## Proposed changes

cherry pick from #41283
This commit is contained in:
924060929
2024-09-26 22:52:51 +08:00
committed by GitHub
parent bf3d4240be
commit e6ce4a2c26

View File

@ -18,6 +18,7 @@
package org.apache.doris.catalog;
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.CastExpr;
import org.apache.doris.analysis.CreateMaterializedViewStmt;
import org.apache.doris.analysis.Expr;
import org.apache.doris.analysis.SlotRef;
@ -214,6 +215,24 @@ public class MaterializedIndexMeta implements Writable, GsonPostProcessable {
}
}
boolean isCastSlot =
entry.getValue() instanceof CastExpr && entry.getValue().getChild(0) instanceof SlotRef;
// Compatibility code for older versions of mv
// old version:
// goods_number -> mva_SUM__CAST(`goods_number` AS BIGINT)
// new version:
// goods_number -> mva_SUM__CAST(`goods_number` AS bigint)
if (isCastSlot && !match) {
for (Column column : schema) {
if (column.getName().equalsIgnoreCase(entry.getKey())) {
column.setDefineExpr(entry.getValue());
match = true;
break;
}
}
}
if (!match) {
// Compatibility code for older versions of mv
// store_id -> mv_store_id