You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/01/28 03:24:05 UTC

[doris] branch branch-1.2-lts updated: [fix](planner) Keep type of null literal expr when register conjuncts (#16147)

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


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 7de71c5937 [fix](planner) Keep type of null literal expr when register conjuncts (#16147)
7de71c5937 is described below

commit 7de71c5937dc8c14caacee4f223512c9c0af4e3f
Author: AKIRA <33...@users.noreply.github.com>
AuthorDate: Sat Jan 28 11:23:58 2023 +0800

    [fix](planner) Keep type of null literal expr when register conjuncts (#16147)
    
    For now, type information of child expr which is `NullLiteral`  would get lost in the `CastExpr#getResultValue`,
    this will  produce a `NullLiteral` with `Null ` type which cause BE core when doing cast
---
 .../java/org/apache/doris/analysis/CastExpr.java   |  2 +-
 .../org/apache/doris/analysis/FunctionParams.java  |  2 +-
 .../data/bitmap_functions/test_bitmap_max.out      |  6 +++
 .../suites/bitmap_functions/test_bitmap_max.groovy | 48 ++++++++++++++++++++++
 4 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
index 491f6e836c..d7d5c07c38 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CastExpr.java
@@ -417,7 +417,7 @@ public class CastExpr extends Expr {
 
     private Expr castTo(LiteralExpr value) throws AnalysisException {
         if (value instanceof NullLiteral) {
-            return value;
+            return NullLiteral.create(targetTypeDef.getType());
         } else if (type.isIntegerType()) {
             return new IntLiteral(value.getLongValue(), type);
         } else if (type.isLargeIntType()) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionParams.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionParams.java
index 683095c7cf..38476449df 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionParams.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionParams.java
@@ -75,7 +75,7 @@ public class FunctionParams implements Writable {
     }
 
     public TAggregateExpr createTAggregateExpr(boolean isMergeAggFn) {
-        List<TTypeDesc> paramTypes = new ArrayList<TTypeDesc>();
+        List<TTypeDesc> paramTypes = new ArrayList<>();
         if (exprs != null) {
             for (Expr expr : exprs) {
                 TTypeDesc desc = expr.getType().toThrift();
diff --git a/regression-test/data/bitmap_functions/test_bitmap_max.out b/regression-test/data/bitmap_functions/test_bitmap_max.out
new file mode 100644
index 0000000000..4c443b8493
--- /dev/null
+++ b/regression-test/data/bitmap_functions/test_bitmap_max.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+1
+2
+3
+
diff --git a/regression-test/suites/bitmap_functions/test_bitmap_max.groovy b/regression-test/suites/bitmap_functions/test_bitmap_max.groovy
new file mode 100644
index 0000000000..267ca0b60c
--- /dev/null
+++ b/regression-test/suites/bitmap_functions/test_bitmap_max.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_bitmap_max") {
+    sql """DROP TABLE IF EXISTS  t1;"""
+
+    sql """
+            CREATE TABLE `t1`
+            (
+                `col1` INT,
+                `col2` bitmap BITMAP_UNION NOT NULL COMMENT ""
+            ) ENGINE = OLAP AGGREGATE KEY(`col1`)
+                DISTRIBUTED BY HASH(`col1`) BUCKETS 4
+                PROPERTIES (
+                        "replication_allocation" = "tag.location.default: 1"
+            );
+    """
+
+    sql """
+            INSERT INTO t1 VALUES(1, to_bitmap(1)),
+                (2, to_bitmap(2)),
+                (3, to_bitmap(3));
+    """
+
+    order_qt_select """
+            SELECT /*+ SET_VAR(query_timeout = 600) */
+                Coalesce(Bitmap_max(Cast(
+                Bitmap_empty() AS BITMAP)), a.`col1`)
+                AS c4
+            FROM   t1 AS a
+            WHERE  Bitmap_max(Cast(NULL AS BITMAP)) IS NULL;
+    """
+
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org