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

commit c7b9feb5a104dcb962e98faa9709d17fdecb566b
Author: starocean999 <[email protected]>
AuthorDate: Sat Oct 7 11:27:19 2023 +0800

    [fix](planner)the common type of date and decimal should be  double (#24956)
---
 .../java/org/apache/doris/catalog/ScalarType.java  | 21 +++--------------
 .../data/correctness_p0/test_cast_date_decimal.out |  4 ++++
 .../correctness_p0/test_cast_date_decimal.groovy   | 26 ++++++++++++++++++++++
 3 files changed, 33 insertions(+), 18 deletions(-)

diff --git 
a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java 
b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
index e3f1b518d05..88c0023fba6 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/ScalarType.java
@@ -1052,24 +1052,9 @@ public class ScalarType extends Type {
             return createVarcharType(Math.max(t1.len, t2.len));
         }
 
-        if (t1.isDecimalV2() && t2.isDate()
-                || t1.isDate() && t2.isDecimalV2()) {
-            return INVALID;
-        }
-
-        if ((t1.isDecimalV2() && t2.isDateV2())
-                || (t1.isDateV2() && t2.isDecimalV2())) {
-            return INVALID;
-        }
-
-        if ((t1.isDecimalV3() && t2.isDate())
-                || (t1.isDate() && t2.isDecimalV3())) {
-            return INVALID;
-        }
-
-        if ((t1.isDecimalV3() && t2.isDateV2())
-                || (t1.isDateV2() && t2.isDecimalV3())) {
-            return INVALID;
+        if (((t1.isDecimalV3() || t1.isDecimalV2()) && (t2.isDateV2() || 
t2.isDate()))
+                || ((t2.isDecimalV3() || t2.isDecimalV2()) && (t1.isDateV2() 
|| t1.isDate()))) {
+            return Type.DOUBLE;
         }
 
         if (t1.isDecimalV2() && t2.isDecimalV2()) {
diff --git a/regression-test/data/correctness_p0/test_cast_date_decimal.out 
b/regression-test/data/correctness_p0/test_cast_date_decimal.out
new file mode 100644
index 00000000000..5b10e282f28
--- /dev/null
+++ b/regression-test/data/correctness_p0/test_cast_date_decimal.out
@@ -0,0 +1,4 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+true
+
diff --git 
a/regression-test/suites/correctness_p0/test_cast_date_decimal.groovy 
b/regression-test/suites/correctness_p0/test_cast_date_decimal.groovy
new file mode 100644
index 00000000000..a2d00c05efe
--- /dev/null
+++ b/regression-test/suites/correctness_p0/test_cast_date_decimal.groovy
@@ -0,0 +1,26 @@
+// 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_cast_date_decimal") {
+    sql """
+        set enable_nereids_planner=false;
+    """
+
+    qt_sql """
+        select cast('2020-02-02' as date ) between cast('2020-02-02' as date ) 
and cast('2020-02-02' as date ) + 1.0;
+    """
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to