[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
This commit is contained in:
yinzhijian
2022-06-10 15:03:09 +08:00
committed by GitHub
parent 495c34fa29
commit 4135e59f77

View File

@ -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));