This is an automated email from the ASF dual-hosted git repository.

morningman 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 acf07d8966 [test] Add bitmap_intersect and schema_change test for 
regression test. (#9854)
acf07d8966 is described below

commit acf07d89665338ea253daba03c24919b985bb510
Author: Hong Liu <844981...@qq.com>
AuthorDate: Mon Jun 20 09:51:31 2022 +0800

    [test] Add bitmap_intersect and schema_change test for regression test. 
(#9854)
---
 .../bitmap_functions/test_bitmap_intersect.out     | 13 ++++
 .../data/schema_change/test_schema_change.out      | 14 ++++
 .../bitmap_functions/test_bitmap_intersect.groovy  | 87 ++++++++++++++++++++++
 .../suites/schema_change/test_schema_change.groovy | 45 ++++++++++-
 4 files changed, 158 insertions(+), 1 deletion(-)

diff --git a/regression-test/data/bitmap_functions/test_bitmap_intersect.out 
b/regression-test/data/bitmap_functions/test_bitmap_intersect.out
new file mode 100644
index 0000000000..721f98e2be
--- /dev/null
+++ b/regression-test/data/bitmap_functions/test_bitmap_intersect.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+1,2
+
+-- !sql --
+
+
+-- !sql --
+1,2
+
+-- !sql --
+
+
diff --git a/regression-test/data/schema_change/test_schema_change.out 
b/regression-test/data/schema_change/test_schema_change.out
new file mode 100644
index 0000000000..84ee227ec5
--- /dev/null
+++ b/regression-test/data/schema_change/test_schema_change.out
@@ -0,0 +1,14 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !desc_uniq_table --
+event_day      DATE    Yes     true    \N      
+siteid INT     Yes     true    10      
+citycode       TEXT    Yes     false   \N      REPLACE
+username       VARCHAR(32)     Yes     false           REPLACE
+pv     BIGINT  Yes     false   0       REPLACE
+
+-- !sql --
+2021-11-01     1       1       用户A     3
+2021-11-02     1       1       用户B     1
+2021-11-02     101     112332121       用户B     112312
+2021-11-02     103     112332211       用户B     112312
+
diff --git 
a/regression-test/suites/bitmap_functions/test_bitmap_intersect.groovy 
b/regression-test/suites/bitmap_functions/test_bitmap_intersect.groovy
new file mode 100644
index 0000000000..1301c308b1
--- /dev/null
+++ b/regression-test/suites/bitmap_functions/test_bitmap_intersect.groovy
@@ -0,0 +1,87 @@
+// 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_intersect", "bitmap_function") {
+
+    def tbName = "test_bitmap_intersect"
+    sql """ SET enable_vectorized_engine = FALSE; """
+    sql """ DROP TABLE IF EXISTS ${tbName} """
+    sql """ create table ${tbName} (tag varchar(20),user_ids bitmap 
bitmap_union) aggregate key (tag) distributed by hash (tag) 
PROPERTIES("replication_num" = "1"); """
+    sql """ insert into ${tbName} values('A', to_bitmap(1)); """
+    sql """ insert into ${tbName} values('A', to_bitmap(2)); """
+    sql """ insert into ${tbName} values('A', to_bitmap(3)); """
+    sql """ insert into ${tbName} values('B', to_bitmap(1)); """
+    sql """ insert into ${tbName} values('B', to_bitmap(2)); """
+
+
+   qt_sql  """ select
+       bitmap_to_string(bitmap_intersect(user_ids))
+       from
+       (
+           select
+             tag,
+             bitmap_union(user_ids) user_ids
+           from
+             ${tbName}
+           group by
+             tag 
+       ) t
+       """
+   qt_sql  """ select
+       bitmap_to_string(bitmap_intersect(user_ids))
+       from
+       (
+           select
+             tag,
+             bitmap_union(user_ids) user_ids
+           from
+             ${tbName}
+           group by
+             tag having tag not in ("A","B")
+       ) t
+       """
+
+    sql """ SET enable_vectorized_engine = true; """
+    qt_sql  """ select
+       bitmap_to_string(bitmap_intersect(user_ids))
+       from
+       (
+           select
+             tag,
+             bitmap_union(user_ids) user_ids
+           from
+             ${tbName}
+           group by
+             tag 
+       ) t
+       """
+    qt_sql  """ select
+       bitmap_to_string(bitmap_intersect(user_ids))
+       from
+       (
+           select
+             tag,
+             bitmap_union(user_ids) user_ids
+           from
+             ${tbName}
+           group by
+             tag having tag not in ("A","B")
+       ) t
+       """
+
+    sql """ DROP TABLE  ${tbName} """
+}
diff --git a/regression-test/suites/schema_change/test_schema_change.groovy 
b/regression-test/suites/schema_change/test_schema_change.groovy
index fe0954f65b..76d9db4722 100644
--- a/regression-test/suites/schema_change/test_schema_change.groovy
+++ b/regression-test/suites/schema_change/test_schema_change.groovy
@@ -17,5 +17,48 @@
 
 suite("test_schema_change", "schema_change") {
      // todo: test alter table schema change, such as add/drop/modify/order 
column
-     sql "show alter table column"
+     def tbName = "alter_table_column_type"
+
+     def getJobState = { tableName ->
+          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
TableName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+          return jobStateResult[0][9]
+     }
+
+     sql """ DROP TABLE IF EXISTS ${tbName} """
+     sql """
+            CREATE TABLE ${tbName}
+            (
+                event_day DATE,
+                siteid INT DEFAULT '10',
+                citycode bigint,
+                username VARCHAR(32) DEFAULT '',
+                pv BIGINT DEFAULT '0'
+            )
+            UNIQUE  KEY(event_day,siteid)
+            PARTITION BY RANGE(event_day)
+            (
+                PARTITION p201706 VALUES LESS THAN ('2021-11-01'),
+                PARTITION p201707 VALUES LESS THAN ('2021-12-01')
+            )
+            DISTRIBUTED BY HASH(siteid) BUCKETS 5
+            PROPERTIES("replication_num" = "1"); 
+         """
+     sql """ insert into ${tbName} 
values('2021-11-01',1,1,'用户A',1),('2021-11-01',1,1,'用户B',1),('2021-11-01',1,1,'用户A',3),('2021-11-02',1,1,'用户A',1),('2021-11-02',1,1,'用户B',1),('2021-11-02',101,112332121,'用户B',112312),('2021-11-02',103,112332211,'用户B',112312);
 """
+     sql """ alter  table ${tbName} modify column citycode string """
+
+     int max_try_time = 100
+     while(max_try_time--){
+          String result = getJobState(tbName)
+          if (result == "FINISHED") {
+               qt_desc_uniq_table """ desc ${tbName} """
+               qt_sql """ SELECT * FROM ${tbName} order by event_day,citycode  
"""
+               sql """ DROP TABLE  ${tbName} """
+               break
+          } else {
+               sleep(1000)
+               if (max_try_time < 1){
+                    assertEquals(1,2)
+               }
+          }
+     }
 }


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

Reply via email to