[fix](planner)cast floating point type to bigint for bit functions (#26598)
This commit is contained in:
@ -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) {
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
-- This file is automatically generated. You should know what you did if you want to edit this
|
||||
-- !select --
|
||||
64 123713 123649 -322
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
suite("test_bit_functions") {
|
||||
sql "SET enable_nereids_planner=false"
|
||||
qt_select 'select bitand(123456, 321.0), bitor(123456, 321.0), bitxor(123456, 321.0), bitnot(321.0);'
|
||||
}
|
||||
Reference in New Issue
Block a user