[fix](planner)shouldn't change the child type to assignmentCompatibleType if it's INVALID_TYPE (#22841)

if changing the child type to INVALID_TYPE, the later getBuiltinFunction call will fail
This commit is contained in:
starocean999
2023-08-11 17:14:49 +08:00
committed by GitHub
parent bcac160013
commit 548226acfc
3 changed files with 20 additions and 12 deletions

View File

@ -1411,20 +1411,22 @@ public class FunctionCallExpr extends Expr {
} else if (fnName.getFunction().equalsIgnoreCase("ifnull")) {
Type[] childTypes = collectChildReturnTypes();
Type assignmentCompatibleType = ScalarType.getAssignmentCompatibleType(childTypes[0], childTypes[1], true);
if (assignmentCompatibleType.isDecimalV3()) {
if (assignmentCompatibleType.isDecimalV3() && !childTypes[0].equals(assignmentCompatibleType)) {
uncheckedCastChild(assignmentCompatibleType, 0);
if (assignmentCompatibleType != Type.INVALID) {
if (assignmentCompatibleType.isDecimalV3()) {
if (assignmentCompatibleType.isDecimalV3() && !childTypes[0].equals(assignmentCompatibleType)) {
uncheckedCastChild(assignmentCompatibleType, 0);
}
if (assignmentCompatibleType.isDecimalV3() && !childTypes[1].equals(assignmentCompatibleType)) {
uncheckedCastChild(assignmentCompatibleType, 1);
}
}
if (assignmentCompatibleType.isDecimalV3() && !childTypes[1].equals(assignmentCompatibleType)) {
uncheckedCastChild(assignmentCompatibleType, 1);
}
}
childTypes[0] = assignmentCompatibleType;
childTypes[1] = assignmentCompatibleType;
childTypes[0] = assignmentCompatibleType;
childTypes[1] = assignmentCompatibleType;
if (childTypes[1].isDecimalV3() && childTypes[0].isDecimalV3()) {
argTypes[1] = assignmentCompatibleType;
argTypes[0] = assignmentCompatibleType;
if (childTypes[1].isDecimalV3() && childTypes[0].isDecimalV3()) {
argTypes[1] = assignmentCompatibleType;
argTypes[0] = assignmentCompatibleType;
}
}
fn = getBuiltinFunction(fnName.getFunction(), childTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);

View File

@ -5,3 +5,6 @@
-- !select_geo1 --
POINT (123.123456789 89.123456789)
-- !select2 --
20230101

View File

@ -18,4 +18,7 @@
suite("test_select_constant") {
qt_select1 'select 100, "test", date("2021-01-02");'
qt_select_geo1 'SELECT ST_AsText(ST_Point(123.12345678901234567890,89.1234567890));'
sql "set enable_nereids_planner=false;"
qt_select2 """select ifnull(cast('2023-01-01' as DATE) ,0);"""
}