diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java index beb7b506de239f..06c8da2dd9ffb7 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java @@ -17,7 +17,6 @@ package org.apache.doris.planner; -import com.google.common.collect.Lists; import org.apache.doris.analysis.CreateDbStmt; import org.apache.doris.analysis.CreateTableStmt; import org.apache.doris.analysis.DropDbStmt; @@ -41,6 +40,8 @@ import org.apache.doris.qe.QueryState.MysqlStateType; import org.apache.doris.utframe.UtFrameUtils; +import com.google.common.collect.Lists; + import org.apache.commons.lang3.StringUtils; import org.junit.AfterClass; import org.junit.Assert; @@ -136,7 +137,8 @@ public static void beforeClass() throws Exception { createTable("CREATE TABLE test.bitmap_table_2 (\n" + " `id` int(11) NULL COMMENT \"\",\n" + - " `id2` bitmap bitmap_union NULL\n" + + " `id2` bitmap bitmap_union NULL,\n" + + " `id3` bitmap bitmap_union NULL\n" + ") ENGINE=OLAP\n" + "AGGREGATE KEY(`id`)\n" + "DISTRIBUTED BY HASH(`id`) BUCKETS 1\n" + @@ -530,6 +532,18 @@ public void testCountDistinctRewrite() throws Exception { explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql); Assert.assertTrue(explainString.contains("bitmap_union_count")); + sql = "select count(distinct if(id = 1, id2, null)) from test.bitmap_table"; + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql); + Assert.assertTrue(explainString.contains("bitmap_union_count")); + + sql = "select count(distinct ifnull(id2, id3)) from test.bitmap_table_2"; + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql); + Assert.assertTrue(explainString.contains("bitmap_union_count")); + + sql = "select count(distinct coalesce(id2, id3)) from test.bitmap_table_2"; + explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql); + Assert.assertTrue(explainString.contains("bitmap_union_count")); + ConnectContext.get().getSessionVariable().setRewriteCountDistinct(false); sql = "select count(distinct id2) from test.bitmap_table"; explainString = UtFrameUtils.getSQLPlanOrErrorMsg(connectContext, "explain " + sql); diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py index b5b9c0e17a1c11..7b6d60fba94a12 100755 --- a/gensrc/script/doris_builtins_functions.py +++ b/gensrc/script/doris_builtins_functions.py @@ -461,6 +461,7 @@ [['if'], 'DATE', ['BOOLEAN', 'DATE', 'DATE'], ''], [['if'], 'DECIMAL', ['BOOLEAN', 'DECIMAL', 'DECIMAL'], ''], [['if'], 'DECIMALV2', ['BOOLEAN', 'DECIMALV2', 'DECIMALV2'], ''], + [['if'], 'BITMAP', ['BOOLEAN', 'BITMAP', 'BITMAP'], ''], # The priority of varchar should be lower than decimal in IS_SUPERTYPE_OF mode. [['if'], 'VARCHAR', ['BOOLEAN', 'VARCHAR', 'VARCHAR'], ''], @@ -493,6 +494,7 @@ [['ifnull'], 'DATETIME', ['DATETIME', 'DATE'], ''], [['ifnull'], 'DECIMAL', ['DECIMAL', 'DECIMAL'], ''], [['ifnull'], 'DECIMALV2', ['DECIMALV2', 'DECIMALV2'], ''], + [['ifnull'], 'BITMAP', ['BITMAP', 'BITMAP'], ''], # The priority of varchar should be lower than decimal in IS_SUPERTYPE_OF mode. [['ifnull'], 'VARCHAR', ['VARCHAR', 'VARCHAR'], ''], @@ -508,6 +510,7 @@ [['coalesce'], 'DATE', ['DATE', '...'], ''], [['coalesce'], 'DECIMAL', ['DECIMAL', '...'], ''], [['coalesce'], 'DECIMALV2', ['DECIMALV2', '...'], ''], + [['coalesce'], 'BITMAP', ['BITMAP', '...'], ''], # The priority of varchar should be lower than decimal in IS_SUPERTYPE_OF mode. [['coalesce'], 'VARCHAR', ['VARCHAR', '...'], ''],