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 paramTypes = new ArrayList(); + List 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