This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 94fbd3ae1638c6efb2801a1b6c1e2e7aa135eb31
Author: starocean999 <[email protected]>
AuthorDate: Wed May 17 15:06:43 2023 +0800

    [fix](planner)just return non-empty side of ExprSubstitutionMap if one of 
ExprSubstitutionMap is empty (#19600)
---
 .../apache/doris/analysis/ExprSubstitutionMap.java |  4 +-
 .../datatype_p0/decimalv3/test_if_functions.out    |  5 +++
 .../datatype_p0/decimalv3/test_if_functions.groovy | 48 ++++++++++++++++++++++
 3 files changed, 55 insertions(+), 2 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
index d9b012c6b4..b88d7a91e9 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ExprSubstitutionMap.java
@@ -143,7 +143,7 @@ public final class ExprSubstitutionMap {
         if (f == null) {
             return g;
         }
-        if (g == null) {
+        if (g == null || g.size() == 0) {
             return f;
         }
         ExprSubstitutionMap result = new ExprSubstitutionMap();
@@ -219,7 +219,7 @@ public final class ExprSubstitutionMap {
         if (f == null) {
             return g;
         }
-        if (g == null) {
+        if (g == null || g.size() == 0) {
             return f;
         }
         ExprSubstitutionMap result = new ExprSubstitutionMap();
diff --git a/regression-test/data/datatype_p0/decimalv3/test_if_functions.out 
b/regression-test/data/datatype_p0/decimalv3/test_if_functions.out
new file mode 100644
index 0000000000..738af7f928
--- /dev/null
+++ b/regression-test/data/datatype_p0/decimalv3/test_if_functions.out
@@ -0,0 +1,5 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select1 --
+0.00
+3.40
+
diff --git 
a/regression-test/suites/datatype_p0/decimalv3/test_if_functions.groovy 
b/regression-test/suites/datatype_p0/decimalv3/test_if_functions.groovy
new file mode 100644
index 0000000000..1b293e4938
--- /dev/null
+++ b/regression-test/suites/datatype_p0/decimalv3/test_if_functions.groovy
@@ -0,0 +1,48 @@
+// 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_if_functions") {
+    sql "drop table if exists test_query_ifnull"
+
+    sql """
+    CREATE TABLE test_query_ifnull(
+        `id` int(11) not null,
+        `value` decimalv3(16, 2) NULL,
+        `flag` varchar(5) null
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`id`)
+    COMMENT "OLAP"
+    DISTRIBUTED BY HASH(`id`) BUCKETS 1
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1",
+    "in_memory" = "false",
+    "storage_format" = "V2"
+    );
+    """
+
+    sql """insert into test_query_ifnull values(1, null, '3'), (2, 3.4, '3')"""
+    qt_select1 """select
+                        if (flag_value is null, 0, flag_value)
+                    from (
+                        select
+                            id,
+                            if (flag = 3, value, 0) flag_value
+                        from
+                            test_query_ifnull) t1
+                    order by id;"""
+    sql "drop table if exists test_query_ifnull"
+}


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

Reply via email to