You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by li...@apache.org on 2023/01/09 07:17:05 UTC
[doris] branch master updated: [Bug](DECIMALV3) Fix binary predicate between decimalv3 and float (#15696)
This is an automated email from the ASF dual-hosted git repository.
lihaopeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new e2492cf7fc [Bug](DECIMALV3) Fix binary predicate between decimalv3 and float (#15696)
e2492cf7fc is described below
commit e2492cf7fc9b9a97280f0a6a8646364694f9c1d1
Author: Gabriel <ga...@gmail.com>
AuthorDate: Mon Jan 9 15:16:59 2023 +0800
[Bug](DECIMALV3) Fix binary predicate between decimalv3 and float (#15696)
---
.../org/apache/doris/analysis/BinaryPredicate.java | 3 +-
.../data/datatype_p0/decimalv3/test_predicate.out | 9 +++++
.../datatype_p0/decimalv3/test_predicate.groovy | 46 ++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
index 98827adc06..cb709eee86 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/BinaryPredicate.java
@@ -390,7 +390,8 @@ public class BinaryPredicate extends Predicate implements Writable {
}
}
- if ((t1.isDecimalV3Type() && !t2.isStringType()) || (t2.isDecimalV3Type() && !t1.isStringType())) {
+ if ((t1.isDecimalV3Type() && !t2.isStringType() && !t2.isFloatingPointType())
+ || (t2.isDecimalV3Type() && !t1.isStringType() && !t1.isFloatingPointType())) {
return Type.getAssignmentCompatibleType(getChild(0).getType(), getChild(1).getType(), false);
}
diff --git a/regression-test/data/datatype_p0/decimalv3/test_predicate.out b/regression-test/data/datatype_p0/decimalv3/test_predicate.out
new file mode 100644
index 0000000000..4873a90ae5
--- /dev/null
+++ b/regression-test/data/datatype_p0/decimalv3/test_predicate.out
@@ -0,0 +1,9 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select1 --
+true
+
+-- !select2 --
+1
+1
+1
+
diff --git a/regression-test/suites/datatype_p0/decimalv3/test_predicate.groovy b/regression-test/suites/datatype_p0/decimalv3/test_predicate.groovy
new file mode 100644
index 0000000000..a2be69952d
--- /dev/null
+++ b/regression-test/suites/datatype_p0/decimalv3/test_predicate.groovy
@@ -0,0 +1,46 @@
+// 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_predicate") {
+ def table1 = "test_predicate"
+
+ sql "drop table if exists ${table1}"
+
+ sql """
+ CREATE TABLE IF NOT EXISTS `${table1}` (
+ `k1` decimalv3(38, 18) NULL COMMENT "",
+ `k2` decimalv3(38, 18) NULL COMMENT "",
+ `k3` decimalv3(38, 18) NULL COMMENT ""
+ ) ENGINE=OLAP
+ COMMENT "OLAP"
+ DISTRIBUTED BY HASH(`k1`, `k2`, `k3`) BUCKETS 8
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 1",
+ "in_memory" = "false",
+ "storage_format" = "V2"
+ )
+ """
+
+ sql """insert into ${table1} values(1.1,1.2,1.3),
+ (1.2,1.2,1.3),
+ (1.5,1.2,1.3)
+ """
+ qt_select1 "select CAST((CASE WHEN (TRUE IS NOT NULL) THEN '1.2' ELSE '1.2' END) AS FLOAT) = CAST(1.2 AS decimal(2,1))"
+
+ qt_select2 "select 1 from ${table1} where CAST((CASE WHEN (TRUE IS NOT NULL) THEN '1.2' ELSE '1.2' END) AS FLOAT) = CAST(1.2 AS decimal(2,1));"
+ sql "drop table if exists ${table1}"
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org