[fix](planner)cast floating point type to bigint for bit functions (#26598)

This commit is contained in:
starocean999
2023-11-09 18:06:06 +08:00
committed by GitHub
parent a5565f68b2
commit fac1b2b192
3 changed files with 46 additions and 0 deletions

View File

@ -1592,6 +1592,27 @@ public class FunctionCallExpr extends Expr {
args[0] = Type.DOUBLE;
System.arraycopy(childrenTypes, 1, args, 1, childrenTypes.length - 1);
fn = getBuiltinFunction(fnName.getFunction(), args, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
} else if (fnName.getFunction().equalsIgnoreCase("bitand")
|| fnName.getFunction().equalsIgnoreCase("bitor")
|| fnName.getFunction().equalsIgnoreCase("bitxor")) {
Type[] childTypes = collectChildReturnTypes();
if (Arrays.stream(childTypes).anyMatch(child -> child.isDecimalV2()
|| child.isDecimalV3() || child.isFloatingPointType())) {
uncheckedCastChild(Type.BIGINT, 0);
uncheckedCastChild(Type.BIGINT, 1);
argTypes[0] = Type.BIGINT;
argTypes[1] = Type.BIGINT;
}
fn = getBuiltinFunction(fnName.getFunction(), argTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
} else if (fnName.getFunction().equalsIgnoreCase("bitnot")) {
if (children.get(0).type.isDecimalV2() || children.get(0).type.isDecimalV3()
|| children.get(0).type.isFloatingPointType()) {
uncheckedCastChild(Type.BIGINT, 0);
argTypes[0] = Type.BIGINT;
}
fn = getBuiltinFunction(fnName.getFunction(), argTypes,
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
} else {
// now first find table function in table function sets
if (isTableFnCall) {