1+ // Licensed to the Apache Software Foundation (ASF) under one
2+ // or more contributor license agreements. See the NOTICE file
3+ // distributed with this work for additional information
4+ // regarding copyright ownership. The ASF licenses this file
5+ // to you under the Apache License, Version 2.0 (the
6+ // "License"); you may not use this file except in compliance
7+ // with the License. You may obtain a copy of the License at
8+ //
9+ // http://www.apache.org/licenses/LICENSE-2.0
10+ //
11+ // Unless required by applicable law or agreed to in writing,
12+ // software distributed under the License is distributed on an
13+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ // KIND, either express or implied. See the License for the
15+ // specific language governing permissions and limitations
16+ // under the License.
17+
18+ suite(" test_default_bitmap_empty" ) {
19+ sql " SET enable_nereids_planner=true"
20+ sql " SET enable_fallback_to_original_planner=false"
21+ def tableName = " test_default_bitmap_empty"
22+
23+ sql """ DROP TABLE IF EXISTS ${ tableName} """
24+ sql """
25+ CREATE TABLE IF NOT EXISTS ${ tableName}
26+ (
27+ k TINYINT,
28+ v1 bitmap NOT NULL DEFAULT bitmap_empty,
29+ v2 INT
30+ )
31+ UNIQUE KEY(K)
32+ DISTRIBUTED BY HASH(k)
33+ PROPERTIES("replication_num" = "1");
34+ """
35+
36+ // test insert into.
37+ sql " insert into ${ tableName} (k, v2) values (1, 1); "
38+ sql " insert into ${ tableName} (k, v2) values (2, 2); "
39+ sql " insert into ${ tableName} (k, v2) values (3, 3); "
40+ sql " insert into ${ tableName} (k, v2) values (4, 4); "
41+ sql " sync"
42+ qt_insert_into1 """ select bitmap_count(v1) from ${ tableName} ; """
43+
44+ // test csv stream load.
45+ streamLoad {
46+ table " ${ tableName} "
47+
48+ set ' column_separator' , ' ,'
49+ set ' columns' , ' k, v1=bitmap_empty(), v2'
50+
51+ file ' test_default_bitmap_empty_streamload.csv'
52+
53+ time 10000 // limit inflight 10s
54+ }
55+
56+ sql " sync"
57+
58+ qt_stream_load_csv1 """ select bitmap_count(v1) from ${ tableName} ; """
59+
60+ // test partial update
61+ sql """ DROP TABLE IF EXISTS ${ tableName} """
62+ sql """
63+ CREATE TABLE IF NOT EXISTS ${ tableName}
64+ (
65+ k TINYINT,
66+ v1 bitmap NOT NULL DEFAULT bitmap_empty,
67+ v2 INT
68+ )
69+ UNIQUE KEY(K)
70+ DISTRIBUTED BY HASH(k)
71+ PROPERTIES("replication_num" = "1");
72+ """
73+
74+ sql " set enable_unique_key_partial_update=true;"
75+ sql " set enable_insert_strict=false;"
76+
77+ sql " insert into ${ tableName} (k, v2) values (1, 1); "
78+ sql " insert into ${ tableName} (k, v2) values (2, 2); "
79+ sql " insert into ${ tableName} (k, v2) values (3, 3); "
80+ sql " insert into ${ tableName} (k, v2) values (4, 4); "
81+ sql " sync"
82+
83+ qt_select_2 " select bitmap_count(v1) from ${ tableName} ;"
84+
85+ streamLoad {
86+ table " ${ tableName} "
87+
88+ set ' partial_columns' , ' true'
89+ set ' column_separator' , ' ,'
90+ set ' columns' , ' k, v2'
91+
92+ file ' test_default_bitmap_empty_streamload.csv'
93+
94+ time 10000 // limit inflight 10s
95+ }
96+
97+ sql " sync"
98+
99+ qt_stream_load_csv2 """ select bitmap_count(v1) from ${ tableName} ; """
100+
101+ sql """ DROP TABLE IF EXISTS ${ tableName} """
102+ sql """
103+ CREATE TABLE IF NOT EXISTS ${ tableName}
104+ (
105+ k TINYINT,
106+ v1 bitmap BITMAP_UNION default BITMAP_EMPTY,
107+ v2 INT replace_if_not_null
108+ )
109+ aggregate KEY(K)
110+ DISTRIBUTED BY HASH(k)
111+ PROPERTIES("replication_num" = "1");
112+ """
113+
114+ // test insert into.
115+ sql " insert into ${ tableName} (k, v2) values (1, 1); "
116+ sql " insert into ${ tableName} (k, v2) values (2, 2); "
117+ sql " insert into ${ tableName} (k, v2) values (3, 3); "
118+ sql " insert into ${ tableName} (k, v2) values (4, 4); "
119+ sql " sync"
120+ qt_insert_into3 """ select bitmap_count(v1) from ${ tableName} ; """
121+
122+ // test csv stream load.
123+ streamLoad {
124+ table " ${ tableName} "
125+
126+ set ' column_separator' , ' ,'
127+ set ' columns' , ' k, v1=bitmap_empty(), v2'
128+
129+ file ' test_default_bitmap_empty_streamload.csv'
130+
131+ time 10000 // limit inflight 10s
132+ }
133+
134+ sql " sync"
135+
136+ qt_stream_load_csv3 """ select bitmap_count(v1) from ${ tableName} ; """
137+ }
0 commit comments