This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 8ca7bd8f981 [enhancement](bitmap)support bitmap type for non-key
column in duplicate table (#28392)
8ca7bd8f981 is described below
commit 8ca7bd8f981825b2124aed7004ad96400d639c09
Author: bobhan1 <[email protected]>
AuthorDate: Thu Dec 14 23:59:12 2023 +0800
[enhancement](bitmap)support bitmap type for non-key column in duplicate
table (#28392)
---
.../sql-manual/sql-reference/Data-Types/BITMAP.md | 4 +-
.../sql-manual/sql-reference/Data-Types/BITMAP.md | 4 +-
.../org/apache/doris/analysis/CreateTableStmt.java | 7 +-
.../plans/commands/info/ColumnDefinition.java | 10 +--
.../duplicate/storage/test_duplicate_bitmap.out | 49 ++++++++++++
.../duplicate/storage/test_duplicate_bitmap.groovy | 89 ++++++++++++++++++++++
6 files changed, 144 insertions(+), 19 deletions(-)
diff --git a/docs/en/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
b/docs/en/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
index 81ec1bae797..cc26c84db17 100644
--- a/docs/en/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
+++ b/docs/en/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
@@ -28,8 +28,8 @@ under the License.
### Description
BITMAP
-The columns of the BITMAP type can be used in Aggregate tables or Unique
tables.
-When used in a Unique table, they must be used as non-key columns.
+The columns of the BITMAP type can be used in Aggregate table, Unique table or
Duplicate table.
+When used in a Unique table or Duplicate table, they must be used as non-key
columns.
When used in an Aggregate table, they must be used as non-key columns, and the
aggregation type is BITMAP_UNION when building the table.
The user does not need to specify the length and default value. The length is
controlled within the system according to the degree of data aggregation.
And the BITMAP column can only be queried or used by supporting functions such
as bitmap_union_count, bitmap_union, bitmap_hash and bitmap_hash64.
diff --git a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
index dee7f760ccc..dbaf47a1faf 100644
--- a/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
+++ b/docs/zh-CN/docs/sql-manual/sql-reference/Data-Types/BITMAP.md
@@ -28,8 +28,8 @@ under the License.
### description
BITMAP
-BITMAP类型的列可以在Aggregate表或Unique表中使用。
-在Unique表中使用时,其必须作为非key列使用。
+BITMAP类型的列可以在Aggregate表、Unique表或Duplicate表中使用。
+在Unique表或duplicate表中使用时,其必须作为非key列使用。
在Aggregate表中使用时,其必须作为非key列使用,且建表时配合的聚合类型为BITMAP_UNION。
用户不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。
并且BITMAP列只能通过配套的bitmap_union_count、bitmap_union、bitmap_hash、bitmap_hash64等函数进行查询或使用。
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
index 45be7a672d7..a7eb62eb368 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
@@ -524,12 +524,7 @@ public class CreateTableStmt extends DdlStmt {
}
if (columnDef.getType().isObjectStored()) {
- if (columnDef.getType().isBitmapType()) {
- if (keysDesc.getKeysType() == KeysType.DUP_KEYS) {
- throw new AnalysisException("column:" +
columnDef.getName()
- + " must be used in AGG_KEYS or UNIQUE_KEYS.");
- }
- } else {
+ if (!columnDef.getType().isBitmapType()) {
if (keysDesc.getKeysType() != KeysType.AGG_KEYS) {
throw new AnalysisException("column:" +
columnDef.getName() + " must be used in AGG_KEYS.");
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
index ff74bd22560..86d48556f87 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
@@ -198,9 +198,6 @@ public class ColumnDefinition {
isNullable = false;
}
if (type.isBitmapType()) {
- if (keysType == KeysType.DUP_KEYS) {
- throw new AnalysisException("column:" + name + " must be used
in AGG_KEYS or UNIQUE_KEYS.");
- }
if (aggType != null) {
isNullable = false;
}
@@ -354,12 +351,7 @@ public class ColumnDefinition {
}
if (type.isObjectType()) {
- if (type.isBitmapType()) {
- if (keysType == KeysType.DUP_KEYS) {
- throw new AnalysisException(
- "column:" + name + " must be used in AGG_KEYS or
UNIQUE_KEYS.");
- }
- } else {
+ if (!type.isBitmapType()) {
if (keysType != KeysType.AGG_KEYS) {
throw new AnalysisException("column:" + name + " must be
used in AGG_KEYS.");
}
diff --git
a/regression-test/data/data_model_p0/duplicate/storage/test_duplicate_bitmap.out
b/regression-test/data/data_model_p0/duplicate/storage/test_duplicate_bitmap.out
new file mode 100644
index 00000000000..28d6859d5f1
--- /dev/null
+++
b/regression-test/data/data_model_p0/duplicate/storage/test_duplicate_bitmap.out
@@ -0,0 +1,49 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !sql --
+1 1 1
+2 2 3,1000
+3 3 999,1000,888888
+
+-- !sql --
+1 1 1
+1 4 5,90,876,1000
+2 2 3,1000
+3 3 999,1000,888888
+3 8 0,1,2,3,5,99,876,2445
+
+-- !sql --
+1 1 1
+1 1 1
+1 4 5,90,876,1000
+1 4 5,90,876,1000
+2 2 3,1000
+2 2 3,1000
+3 3 999,1000,888888
+3 3 999,1000,888888
+3 8 0,1,2,3,5,99,876,2445
+3 8 0,1,2,3,5,99,876,2445
+
+-- !sql --
+1 1 1
+2 2 3,1000
+3 3 999,1000,888888
+
+-- !sql --
+1 1 1
+1 4 5,90,876,1000
+2 2 3,1000
+3 3 999,1000,888888
+3 8 0,1,2,3,5,99,876,2445
+
+-- !sql --
+1 1 1
+1 1 1
+1 4 5,90,876,1000
+1 4 5,90,876,1000
+2 2 3,1000
+2 2 3,1000
+3 3 999,1000,888888
+3 3 999,1000,888888
+3 8 0,1,2,3,5,99,876,2445
+3 8 0,1,2,3,5,99,876,2445
+
diff --git
a/regression-test/suites/data_model_p0/duplicate/storage/test_duplicate_bitmap.groovy
b/regression-test/suites/data_model_p0/duplicate/storage/test_duplicate_bitmap.groovy
new file mode 100644
index 00000000000..9dc9052a481
--- /dev/null
+++
b/regression-test/suites/data_model_p0/duplicate/storage/test_duplicate_bitmap.groovy
@@ -0,0 +1,89 @@
+// 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_duplicate_table_bitmap") {
+
+ // 1. nerieds planner
+ sql "set enable_nereids_planner=true"
+ sql "set enable_fallback_to_original_planner=false"
+ sql "set enable_nereids_dml=true;"
+ sql "sync;"
+ def tbName = "test_duplicate_bitmap1"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ sql """ CREATE TABLE IF NOT EXISTS ${tbName} (
+ k int,
+ id_bitmap bitmap
+ ) DUPLICATE KEY(k)
+ DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" =
"1"); """
+ sql "insert into ${tbName} values(1,to_bitmap(1));"
+ sql "insert into ${tbName}
values(2,bitmap_or(to_bitmap(3),to_bitmap(1000)));"
+ sql "insert into ${tbName}
values(3,bitmap_or(to_bitmap(999),to_bitmap(1000),to_bitmap(888888)));"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "insert into ${tbName}
values(3,bitmap_from_string('1,0,1,2,3,1,5,99,876,2445'));"
+ sql "insert into ${tbName}
values(1,bitmap_or(bitmap_from_string('90,5,876'),to_bitmap(1000)));"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "insert into ${tbName} select * from ${tbName};"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "DROP TABLE IF EXISTS ${tbName};"
+
+ tbName = "test_duplicate_bitmap2"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ test {
+ sql """ CREATE TABLE IF NOT EXISTS ${tbName} (
+ k bitmap,
+ v int
+ ) DUPLICATE KEY(k)
+ DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" =
"1"); """
+ exception "Key column can not set complex type:k"
+ }
+
+
+ // 2. origin planner
+ sql "set enable_nereids_planner=false"
+ sql "set enable_nereids_dml=false;"
+ sql "sync;"
+ tbName = "test_duplicate_bitmap3"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ sql """ CREATE TABLE IF NOT EXISTS ${tbName} (
+ k int,
+ id_bitmap bitmap
+ ) DUPLICATE KEY(k)
+ DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" =
"1"); """
+ sql "insert into ${tbName} values(1,to_bitmap(1));"
+ sql "insert into ${tbName}
values(2,bitmap_or(to_bitmap(3),to_bitmap(1000)));"
+ sql "insert into ${tbName}
values(3,bitmap_or(to_bitmap(999),to_bitmap(1000),to_bitmap(888888)));"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "insert into ${tbName}
values(3,bitmap_from_string('1,0,1,2,3,1,5,99,876,2445'));"
+ sql "insert into ${tbName}
values(1,bitmap_or(bitmap_from_string('90,5,876'),to_bitmap(1000)));"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "insert into ${tbName} select * from ${tbName};"
+ qt_sql "select k,bitmap_count(id_bitmap),bitmap_to_string(id_bitmap) from
${tbName} order by k, bitmap_count(id_bitmap);"
+ sql "DROP TABLE IF EXISTS ${tbName};"
+
+
+ tbName = "test_duplicate_bitmap4"
+ sql "DROP TABLE IF EXISTS ${tbName}"
+ test {
+ sql """ CREATE TABLE IF NOT EXISTS ${tbName} (
+ k bitmap,
+ v int
+ ) DUPLICATE KEY(k)
+ DISTRIBUTED BY HASH(k) BUCKETS 1 properties("replication_num" =
"1"); """
+ exception "Key column can not set complex type:k"
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]