diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java index 10cd2d065c..f5dd01c112 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java @@ -265,6 +265,15 @@ public class CastExpr extends Expr { noOp = true; return; } + // select stmt will make BE coredump when its castExpr is like cast(int as array<>), + // it is necessary to check if it is castable before creating fn. + // char type will fail in canCastTo, so for compatibility, only the cast of array type is checked here. + if (type.isArrayType() || childType.isArrayType()) { + if (!Type.canCastTo(childType, type)) { + throw new AnalysisException("Invalid type cast of " + getChild(0).toSql() + + " from " + childType + " to " + type); + } + } this.opcode = TExprOpcode.CAST; FunctionName fnName = new FunctionName(getFnName(type));