This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b90bbf27ae1 [fix](planner)cast floating point type to bigint for bit
functions #26598 (#26691)
b90bbf27ae1 is described below
commit b90bbf27ae1a1441a8331650736aa1c34527558c
Author: starocean999 <[email protected]>
AuthorDate: Thu Nov 9 23:36:02 2023 +0800
[fix](planner)cast floating point type to bigint for bit functions #26598
(#26691)
---
.../apache/doris/analysis/FunctionCallExpr.java | 21 +++++++++++++++++++++
.../data/correctness_p0/test_bit_function.out | 4 ++++
.../suites/correctness_p0/test_bit_function.groovy | 22 ++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 6345c25395a..bd502d85faa 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1576,6 +1576,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) {
diff --git a/regression-test/data/correctness_p0/test_bit_function.out
b/regression-test/data/correctness_p0/test_bit_function.out
new file mode 100644
index 00000000000..0fe60dde32c
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_bit_function.out
@@ -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
+
diff --git a/regression-test/suites/correctness_p0/test_bit_function.groovy
b/regression-test/suites/correctness_p0/test_bit_function.groovy
new file mode 100644
index 00000000000..0dfdfab703b
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_bit_function.groovy
@@ -0,0 +1,22 @@
+
+// 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);'
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]