From 4135e59f77c1aa5a99c84ebc4175dc3c77b58bbd Mon Sep 17 00:00:00 2001 From: yinzhijian <373141588@qq.com> Date: Fri, 10 Jun 2022 15:03:09 +0800 Subject: [PATCH] [fix](fe) select stmt will make BE coredump when its castExpr is like cast(int as array<>) (#9995) * [fix](fe) select stmt will make BE coredump when its castExpr is like cast(int as array<>) * fix implicit cast scalar type bug * Revert "fix implicit cast scalar type bug" This reverts commit 1f05b6bab72430214dca88f386b50ef9a081e60a. * only check array cast, retrigger --- .../main/java/org/apache/doris/analysis/CastExpr.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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));