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 ec6400f0dc [feature-wip](unique-key-merge-on-write) add regression case (#11731) ec6400f0dc is described below commit ec6400f0dc0781bf1566802e7b93db781a954f81 Author: yixiutt <102007456+yixi...@users.noreply.github.com> AuthorDate: Wed Aug 24 21:27:58 2022 +0800 [feature-wip](unique-key-merge-on-write) add regression case (#11731) Co-authored-by: yixiutt <yi...@selectdb.com> --- .../ssb_unique_sql_zstd_p0/sql/q1.1.out | 4 + .../ssb_unique_sql_zstd_p0/sql/q1.2.out | 4 + .../ssb_unique_sql_zstd_p0/sql/q1.3.out | 4 + .../ssb_unique_sql_zstd_p0/sql/q2.1.out | 43 ++++++++ .../ssb_unique_sql_zstd_p0/sql/q2.2.out | 11 ++ .../ssb_unique_sql_zstd_p0/sql/q2.3.out | 4 + .../ssb_unique_sql_zstd_p0/sql/q3.1.out | 28 ++++++ .../ssb_unique_sql_zstd_p0/sql/q3.2.out | 51 ++++++++++ .../ssb_unique_sql_zstd_p0/sql/q3.3.out | 4 + .../ssb_unique_sql_zstd_p0/sql/q3.4.out | 3 + .../ssb_unique_sql_zstd_p0/sql/q4.1.out | 8 ++ .../ssb_unique_sql_zstd_p0/sql/q4.2.out | 3 + .../ssb_unique_sql_zstd_p0/sql/q4.3.out | 3 + .../ddl/customer_create.sql | 17 ++++ .../ddl/customer_delete.sql | 1 + .../ddl/customer_part_delete.sql | 1 + .../ddl/customer_sequence_create.sql | 18 ++++ .../ssb_unique_load_zstd_p0/ddl/date_create.sql | 26 +++++ .../ssb_unique_load_zstd_p0/ddl/date_delete.sql | 1 + .../ddl/date_part_delete.sql | 1 + .../ddl/date_sequence_create.sql | 27 +++++ .../ddl/lineorder_create.sql | 34 +++++++ .../ddl/lineorder_delete.sql | 1 + .../ddl/lineorder_part_delete.sql | 1 + .../ddl/lineorder_sequence_create.sql | 35 +++++++ .../ssb_unique_load_zstd_p0/ddl/part_create.sql | 18 ++++ .../ssb_unique_load_zstd_p0/ddl/part_delete.sql | 1 + .../ddl/part_part_delete.sql | 1 + .../ddl/part_sequence_create.sql | 19 ++++ .../ddl/supplier_create.sql | 16 +++ .../ddl/supplier_delete.sql | 1 + .../ddl/supplier_part_delete.sql | 1 + .../ddl/supplier_sequence_create.sql | 17 ++++ .../ssb_unique_load_zstd_p0/load_four_step.groovy | 104 +++++++++++++++++++ .../ssb_unique_load_zstd_p0/load_one_step.groovy | 60 +++++++++++ .../ssb_unique_load_zstd_p0/load_three_step.groovy | 69 +++++++++++++ .../ssb_unique_load_zstd_p0/load_two_step.groovy | 67 +++++++++++++ .../ssb_unique_sql_zstd_p0/ddl/customer_create.sql | 17 ++++ .../ssb_unique_sql_zstd_p0/ddl/customer_delete.sql | 1 + .../ssb_unique_sql_zstd_p0/ddl/date_create.sql | 26 +++++ .../ssb_unique_sql_zstd_p0/ddl/date_delete.sql | 1 + .../ddl/lineorder_create.sql | 34 +++++++ .../ddl/lineorder_delete.sql | 1 + .../ssb_unique_sql_zstd_p0/ddl/part_create.sql | 18 ++++ .../ssb_unique_sql_zstd_p0/ddl/part_delete.sql | 1 + .../ssb_unique_sql_zstd_p0/ddl/supplier_create.sql | 16 +++ .../ssb_unique_sql_zstd_p0/ddl/supplier_delete.sql | 1 + .../primary_key/ssb_unique_sql_zstd_p0/load.groovy | 78 +++++++++++++++ .../ssb_unique_sql_zstd_p0/sql/q1.1.sql | 24 +++++ .../ssb_unique_sql_zstd_p0/sql/q1.2.sql | 24 +++++ .../ssb_unique_sql_zstd_p0/sql/q1.3.sql | 25 +++++ .../ssb_unique_sql_zstd_p0/sql/q2.1.sql | 26 +++++ .../ssb_unique_sql_zstd_p0/sql/q2.2.sql | 27 +++++ .../ssb_unique_sql_zstd_p0/sql/q2.3.sql | 26 +++++ .../ssb_unique_sql_zstd_p0/sql/q3.1.sql | 28 ++++++ .../ssb_unique_sql_zstd_p0/sql/q3.2.sql | 28 ++++++ .../ssb_unique_sql_zstd_p0/sql/q3.3.sql | 30 ++++++ .../ssb_unique_sql_zstd_p0/sql/q3.4.sql | 30 ++++++ .../ssb_unique_sql_zstd_p0/sql/q4.1.sql | 30 ++++++ .../ssb_unique_sql_zstd_p0/sql/q4.2.sql | 31 ++++++ .../ssb_unique_sql_zstd_p0/sql/q4.3.sql | 29 ++++++ .../test_primary_key_simple_case.groovy | 111 +++++++++++++++++++++ 62 files changed, 1370 insertions(+) diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.out new file mode 100644 index 0000000000..92604403fd --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q1.1 -- +\N + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.out new file mode 100644 index 0000000000..22731ac444 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q1.2 -- +\N + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.out new file mode 100644 index 0000000000..71908d1f12 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q1.3 -- +\N + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.out new file mode 100644 index 0000000000..9d56f6e633 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.out @@ -0,0 +1,43 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q2.1 -- +29165996 1992 MFGR#121 +23120066 1992 MFGR#1210 +52982362 1992 MFGR#1211 +30954680 1992 MFGR#1212 +15288453 1992 MFGR#1213 +7655070 1992 MFGR#1214 +22246540 1992 MFGR#1215 +19716439 1992 MFGR#1216 +43666251 1992 MFGR#1217 +22759602 1992 MFGR#1218 +23318799 1992 MFGR#1219 +74056106 1992 MFGR#122 +51050565 1992 MFGR#1220 +38878674 1992 MFGR#1221 +16558051 1992 MFGR#1222 +26690787 1992 MFGR#1223 +76498594 1992 MFGR#1224 +32608903 1992 MFGR#1225 +47636685 1992 MFGR#1226 +27691433 1992 MFGR#1227 +32513490 1992 MFGR#1228 +35514258 1992 MFGR#1229 +17199862 1992 MFGR#123 +24678908 1992 MFGR#1230 +26231337 1992 MFGR#1231 +36330900 1992 MFGR#1232 +24946678 1992 MFGR#1233 +36431683 1992 MFGR#1234 +39368479 1992 MFGR#1235 +44456974 1992 MFGR#1236 +31443810 1992 MFGR#1237 +49003021 1992 MFGR#1238 +31379822 1992 MFGR#1239 +24245603 1992 MFGR#124 +49870826 1992 MFGR#1240 +28194770 1992 MFGR#125 +40503844 1992 MFGR#126 +36027836 1992 MFGR#127 +35881895 1992 MFGR#128 +21732451 1992 MFGR#129 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.out new file mode 100644 index 0000000000..debe195012 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.out @@ -0,0 +1,11 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q2.2 -- +28235270 1992 MFGR#2221 +64071827 1992 MFGR#2222 +48591160 1992 MFGR#2223 +20416501 1992 MFGR#2224 +74950776 1992 MFGR#2225 +60628045 1992 MFGR#2226 +39273349 1992 MFGR#2227 +66658087 1992 MFGR#2228 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.out new file mode 100644 index 0000000000..40b3220406 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q2.3 -- +89380397 1992 MFGR#2239 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.out new file mode 100644 index 0000000000..a50f6a20d5 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.out @@ -0,0 +1,28 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q3.1 -- +JAPAN CHINA 1992 637991852 +VIETNAM CHINA 1992 621845377 +INDONESIA CHINA 1992 621316255 +CHINA CHINA 1992 614550901 +INDIA CHINA 1992 561966207 +INDIA INDONESIA 1992 487449629 +INDONESIA INDONESIA 1992 477417717 +JAPAN INDONESIA 1992 476513261 +JAPAN VIETNAM 1992 468999429 +INDONESIA JAPAN 1992 465870469 +VIETNAM INDONESIA 1992 462424521 +INDIA JAPAN 1992 412186106 +JAPAN JAPAN 1992 399179790 +VIETNAM JAPAN 1992 395247587 +JAPAN INDIA 1992 393835589 +CHINA INDONESIA 1992 352903905 +CHINA INDIA 1992 348359904 +VIETNAM VIETNAM 1992 342176333 +INDIA VIETNAM 1992 334582962 +INDIA INDIA 1992 329354089 +CHINA JAPAN 1992 327558220 +CHINA VIETNAM 1992 324763767 +INDONESIA INDIA 1992 310417666 +VIETNAM INDIA 1992 296225919 +INDONESIA VIETNAM 1992 278083418 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.out new file mode 100644 index 0000000000..1109fa3ce8 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.out @@ -0,0 +1,51 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q3.2 -- +UNITED ST4 UNITED ST0 1992 34626982 +UNITED ST4 UNITED ST3 1992 29767238 +UNITED ST1 UNITED ST9 1992 25644597 +UNITED ST2 UNITED ST0 1992 23943154 +UNITED ST4 UNITED ST9 1992 21189183 +UNITED ST0 UNITED ST0 1992 18293852 +UNITED ST7 UNITED ST3 1992 17996772 +UNITED ST9 UNITED ST3 1992 17863433 +UNITED ST1 UNITED ST7 1992 17410800 +UNITED ST2 UNITED ST3 1992 15331073 +UNITED ST5 UNITED ST9 1992 14448179 +UNITED ST1 UNITED ST3 1992 13938002 +UNITED ST5 UNITED ST6 1992 12398029 +UNITED ST9 UNITED ST2 1992 12370917 +UNITED ST2 UNITED ST9 1992 12343455 +UNITED ST5 UNITED ST0 1992 12301234 +UNITED ST6 UNITED ST0 1992 11900889 +UNITED ST4 UNITED ST2 1992 11696334 +UNITED ST4 UNITED ST6 1992 11369008 +UNITED ST1 UNITED ST6 1992 11000283 +UNITED ST1 UNITED ST0 1992 10878084 +UNITED ST4 UNITED ST7 1992 10151573 +UNITED ST5 UNITED ST2 1992 9917834 +UNITED ST7 UNITED ST7 1992 9715656 +UNITED ST6 UNITED ST6 1992 8685228 +UNITED ST2 UNITED ST2 1992 8313714 +UNITED ST1 UNITED ST2 1992 8004700 +UNITED ST2 UNITED ST7 1992 7759164 +UNITED ST0 UNITED ST7 1992 7137641 +UNITED ST9 UNITED ST7 1992 6703890 +UNITED ST6 UNITED ST9 1992 6597261 +UNITED ST7 UNITED ST2 1992 6125476 +UNITED ST7 UNITED ST6 1992 6058017 +UNITED ST5 UNITED ST3 1992 5862031 +UNITED ST8 UNITED ST9 1992 5690491 +UNITED ST7 UNITED ST9 1992 5403152 +UNITED ST9 UNITED ST0 1992 4816370 +UNITED ST9 UNITED ST9 1992 4234523 +UNITED ST3 UNITED ST3 1992 4080199 +UNITED ST5 UNITED ST7 1992 3936271 +UNITED ST8 UNITED ST0 1992 3574169 +UNITED ST0 UNITED ST3 1992 3201624 +UNITED ST3 UNITED ST9 1992 2614811 +UNITED ST8 UNITED ST7 1992 2373825 +UNITED ST9 UNITED ST6 1992 2066609 +UNITED ST7 UNITED ST0 1992 1882015 +UNITED ST6 UNITED ST3 1992 1873819 +UNITED ST6 UNITED ST2 1992 291566 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.out new file mode 100644 index 0000000000..6f33841912 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q3.3 -- +UNITED KI5 UNITED KI1 1992 4397192 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.out new file mode 100644 index 0000000000..3738fc2859 --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q3.4 -- + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.out new file mode 100644 index 0000000000..00bc9ddd7c --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.out @@ -0,0 +1,8 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q4.1 -- +1992 ARGENTINA 533196600 +1992 BRAZIL 684224630 +1992 CANADA 532686194 +1992 PERU 586223155 +1992 UNITED STATES 682387184 + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.out new file mode 100644 index 0000000000..30fae3d4bf --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q4.2 -- + diff --git a/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.out b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.out new file mode 100644 index 0000000000..741016a89d --- /dev/null +++ b/regression-test/data/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.out @@ -0,0 +1,3 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q4.3 -- + diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_create.sql new file mode 100644 index 0000000000..d6566d3f1b --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_create.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS `customer` ( + `c_custkey` int(11) NOT NULL COMMENT "", + `c_name` varchar(26) NOT NULL COMMENT "", + `c_address` varchar(41) NOT NULL COMMENT "", + `c_city` varchar(11) NOT NULL COMMENT "", + `c_nation` varchar(16) NOT NULL COMMENT "", + `c_region` varchar(13) NOT NULL COMMENT "", + `c_phone` varchar(16) NOT NULL COMMENT "", + `c_mktsegment` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`c_custkey`) +DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_delete.sql new file mode 100644 index 0000000000..fe22a226fe --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_delete.sql @@ -0,0 +1 @@ +truncate table customer; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_part_delete.sql new file mode 100644 index 0000000000..a9d1b34d68 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_part_delete.sql @@ -0,0 +1 @@ +delete from customer where c_custkey > 1500 ; diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_sequence_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_sequence_create.sql new file mode 100644 index 0000000000..d1a099e7a5 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/customer_sequence_create.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS `customer` ( + `c_custkey` int(11) NOT NULL COMMENT "", + `c_name` varchar(26) NOT NULL COMMENT "", + `c_address` varchar(41) NOT NULL COMMENT "", + `c_city` varchar(11) NOT NULL COMMENT "", + `c_nation` varchar(16) NOT NULL COMMENT "", + `c_region` varchar(13) NOT NULL COMMENT "", + `c_phone` varchar(16) NOT NULL COMMENT "", + `c_mktsegment` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`c_custkey`) +DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 10 +PROPERTIES ( +"function_column.sequence_type" = 'int', +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_create.sql new file mode 100644 index 0000000000..d6ad38d8bd --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_create.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS `date` ( + `d_datekey` int(11) NOT NULL COMMENT "", + `d_date` varchar(20) NOT NULL COMMENT "", + `d_dayofweek` varchar(10) NOT NULL COMMENT "", + `d_month` varchar(11) NOT NULL COMMENT "", + `d_year` int(11) NOT NULL COMMENT "", + `d_yearmonthnum` int(11) NOT NULL COMMENT "", + `d_yearmonth` varchar(9) NOT NULL COMMENT "", + `d_daynuminweek` int(11) NOT NULL COMMENT "", + `d_daynuminmonth` int(11) NOT NULL COMMENT "", + `d_daynuminyear` int(11) NOT NULL COMMENT "", + `d_monthnuminyear` int(11) NOT NULL COMMENT "", + `d_weeknuminyear` int(11) NOT NULL COMMENT "", + `d_sellingseason` varchar(14) NOT NULL COMMENT "", + `d_lastdayinweekfl` int(11) NOT NULL COMMENT "", + `d_lastdayinmonthfl` int(11) NOT NULL COMMENT "", + `d_holidayfl` int(11) NOT NULL COMMENT "", + `d_weekdayfl` int(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`d_datekey`) +DISTRIBUTED BY HASH(`d_datekey`) BUCKETS 1 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_delete.sql new file mode 100644 index 0000000000..12933cbbad --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_delete.sql @@ -0,0 +1 @@ +truncate table `date`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_part_delete.sql new file mode 100644 index 0000000000..0c21b27cc4 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_part_delete.sql @@ -0,0 +1 @@ +delete from `date` where d_datekey >= '19920701' and d_datekey <= '19920731'; diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_sequence_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_sequence_create.sql new file mode 100644 index 0000000000..36b9fb5991 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/date_sequence_create.sql @@ -0,0 +1,27 @@ +CREATE TABLE IF NOT EXISTS `date` ( + `d_datekey` int(11) NOT NULL COMMENT "", + `d_date` varchar(20) NOT NULL COMMENT "", + `d_dayofweek` varchar(10) NOT NULL COMMENT "", + `d_month` varchar(11) NOT NULL COMMENT "", + `d_year` int(11) NOT NULL COMMENT "", + `d_yearmonthnum` int(11) NOT NULL COMMENT "", + `d_yearmonth` varchar(9) NOT NULL COMMENT "", + `d_daynuminweek` int(11) NOT NULL COMMENT "", + `d_daynuminmonth` int(11) NOT NULL COMMENT "", + `d_daynuminyear` int(11) NOT NULL COMMENT "", + `d_monthnuminyear` int(11) NOT NULL COMMENT "", + `d_weeknuminyear` int(11) NOT NULL COMMENT "", + `d_sellingseason` varchar(14) NOT NULL COMMENT "", + `d_lastdayinweekfl` int(11) NOT NULL COMMENT "", + `d_lastdayinmonthfl` int(11) NOT NULL COMMENT "", + `d_holidayfl` int(11) NOT NULL COMMENT "", + `d_weekdayfl` int(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`d_datekey`) +DISTRIBUTED BY HASH(`d_datekey`) BUCKETS 1 +PROPERTIES ( +"function_column.sequence_type" = 'int', +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_create.sql new file mode 100644 index 0000000000..44bbfaf804 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_create.sql @@ -0,0 +1,34 @@ +CREATE TABLE IF NOT EXISTS `lineorder` ( + `lo_orderdate` int(11) NOT NULL COMMENT "", + `lo_orderkey` bigint(20) NOT NULL COMMENT "", + `lo_linenumber` bigint(20) NOT NULL COMMENT "", + `lo_custkey` int(11) NOT NULL COMMENT "", + `lo_partkey` int(11) NOT NULL COMMENT "", + `lo_suppkey` int(11) NOT NULL COMMENT "", + `lo_orderpriority` varchar(16) NOT NULL COMMENT "", + `lo_shippriority` int(11) NOT NULL COMMENT "", + `lo_quantity` bigint(20) NOT NULL COMMENT "", + `lo_extendedprice` bigint(20) NOT NULL COMMENT "", + `lo_ordtotalprice` bigint(20) NOT NULL COMMENT "", + `lo_discount` bigint(20) NOT NULL COMMENT "", + `lo_revenue` bigint(20) NOT NULL COMMENT "", + `lo_supplycost` bigint(20) NOT NULL COMMENT "", + `lo_tax` bigint(20) NOT NULL COMMENT "", + `lo_commitdate` bigint(20) NOT NULL COMMENT "", + `lo_shipmode` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`lo_orderdate`,`lo_orderkey`,`lo_linenumber`) +PARTITION BY RANGE(`lo_orderdate`) +(PARTITION p1992 VALUES [("-2147483648"), ("19930101")), +PARTITION p1993 VALUES [("19930101"), ("19940101")), +PARTITION p1994 VALUES [("19940101"), ("19950101")), +PARTITION p1995 VALUES [("19950101"), ("19960101")), +PARTITION p1996 VALUES [("19960101"), ("19970101")), +PARTITION p1997 VALUES [("19970101"), ("19980101")), +PARTITION p1998 VALUES [("19980101"), ("19990101"))) +DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 48 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_delete.sql new file mode 100644 index 0000000000..329e040060 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_delete.sql @@ -0,0 +1 @@ +truncate table lineorder; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_part_delete.sql new file mode 100644 index 0000000000..abb7ded433 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_part_delete.sql @@ -0,0 +1 @@ +delete from lineorder where lo_orderkey >= 240001 and lo_orderkey <= 360000; diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_sequence_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_sequence_create.sql new file mode 100644 index 0000000000..cfb3447136 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/lineorder_sequence_create.sql @@ -0,0 +1,35 @@ +CREATE TABLE IF NOT EXISTS `lineorder` ( + `lo_orderdate` int(11) NOT NULL COMMENT "", + `lo_orderkey` bigint(20) NOT NULL COMMENT "", + `lo_linenumber` bigint(20) NOT NULL COMMENT "", + `lo_custkey` int(11) NOT NULL COMMENT "", + `lo_partkey` int(11) NOT NULL COMMENT "", + `lo_suppkey` int(11) NOT NULL COMMENT "", + `lo_orderpriority` varchar(16) NOT NULL COMMENT "", + `lo_shippriority` int(11) NOT NULL COMMENT "", + `lo_quantity` bigint(20) NOT NULL COMMENT "", + `lo_extendedprice` bigint(20) NOT NULL COMMENT "", + `lo_ordtotalprice` bigint(20) NOT NULL COMMENT "", + `lo_discount` bigint(20) NOT NULL COMMENT "", + `lo_revenue` bigint(20) NOT NULL COMMENT "", + `lo_supplycost` bigint(20) NOT NULL COMMENT "", + `lo_tax` bigint(20) NOT NULL COMMENT "", + `lo_commitdate` bigint(20) NOT NULL COMMENT "", + `lo_shipmode` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`lo_orderdate`,`lo_orderkey`,`lo_linenumber`) +PARTITION BY RANGE(`lo_orderdate`) +(PARTITION p1992 VALUES [("-2147483648"), ("19930101")), +PARTITION p1993 VALUES [("19930101"), ("19940101")), +PARTITION p1994 VALUES [("19940101"), ("19950101")), +PARTITION p1995 VALUES [("19950101"), ("19960101")), +PARTITION p1996 VALUES [("19960101"), ("19970101")), +PARTITION p1997 VALUES [("19970101"), ("19980101")), +PARTITION p1998 VALUES [("19980101"), ("19990101"))) +DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 48 +PROPERTIES ( +"function_column.sequence_type" = 'int', +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_create.sql new file mode 100644 index 0000000000..0c6f6e371a --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_create.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS `part` ( + `p_partkey` int(11) NOT NULL COMMENT "", + `p_name` varchar(23) NOT NULL COMMENT "", + `p_mfgr` varchar(7) NOT NULL COMMENT "", + `p_category` varchar(8) NOT NULL COMMENT "", + `p_brand` varchar(10) NOT NULL COMMENT "", + `p_color` varchar(12) NOT NULL COMMENT "", + `p_type` varchar(26) NOT NULL COMMENT "", + `p_size` int(11) NOT NULL COMMENT "", + `p_container` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`p_partkey`) +DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_delete.sql new file mode 100644 index 0000000000..02c6abd253 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_delete.sql @@ -0,0 +1 @@ +truncate table `part`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_part_delete.sql new file mode 100644 index 0000000000..32ec2aa18b --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_part_delete.sql @@ -0,0 +1 @@ +delete from `part` where p_partkey > 10000; diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_sequence_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_sequence_create.sql new file mode 100644 index 0000000000..2ffba863ad --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/part_sequence_create.sql @@ -0,0 +1,19 @@ +CREATE TABLE IF NOT EXISTS `part` ( + `p_partkey` int(11) NOT NULL COMMENT "", + `p_name` varchar(23) NOT NULL COMMENT "", + `p_mfgr` varchar(7) NOT NULL COMMENT "", + `p_category` varchar(8) NOT NULL COMMENT "", + `p_brand` varchar(10) NOT NULL COMMENT "", + `p_color` varchar(12) NOT NULL COMMENT "", + `p_type` varchar(26) NOT NULL COMMENT "", + `p_size` int(11) NOT NULL COMMENT "", + `p_container` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`p_partkey`) +DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 10 +PROPERTIES ( +"function_column.sequence_type" = 'int', +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_create.sql new file mode 100644 index 0000000000..b021767b47 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_create.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS `supplier` ( + `s_suppkey` int(11) NOT NULL COMMENT "", + `s_name` varchar(26) NOT NULL COMMENT "", + `s_address` varchar(26) NOT NULL COMMENT "", + `s_city` varchar(11) NOT NULL COMMENT "", + `s_nation` varchar(16) NOT NULL COMMENT "", + `s_region` varchar(13) NOT NULL COMMENT "", + `s_phone` varchar(16) NOT NULL COMMENT "" +) +UNIQUE KEY (`s_suppkey`) +DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_delete.sql new file mode 100644 index 0000000000..39e663134c --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_delete.sql @@ -0,0 +1 @@ +truncate table `supplier`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_part_delete.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_part_delete.sql new file mode 100644 index 0000000000..ac6a7030fd --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_part_delete.sql @@ -0,0 +1 @@ +delete from `supplier` where s_suppkey > 100; diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_sequence_create.sql b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_sequence_create.sql new file mode 100644 index 0000000000..5a92faef42 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/ddl/supplier_sequence_create.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS `supplier` ( + `s_suppkey` int(11) NOT NULL COMMENT "", + `s_name` varchar(26) NOT NULL COMMENT "", + `s_address` varchar(26) NOT NULL COMMENT "", + `s_city` varchar(11) NOT NULL COMMENT "", + `s_nation` varchar(16) NOT NULL COMMENT "", + `s_region` varchar(13) NOT NULL COMMENT "", + `s_phone` varchar(16) NOT NULL COMMENT "" +) +UNIQUE KEY (`s_suppkey`) +DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 10 +PROPERTIES ( +"function_column.sequence_type" = 'int', +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_four_step.groovy b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_four_step.groovy new file mode 100644 index 0000000000..7ad667c441 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_four_step.groovy @@ -0,0 +1,104 @@ +// 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. + +// Most of the cases are copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases +// and modified by Doris. + +suite("load_four_step") { + def tables = ["customer": ["""c_custkey,c_name,c_address,c_city,c_nation,c_region,c_phone,c_mktsegment,no_use""", 3000, "c_custkey", 1500], "lineorder": ["""lo_orderkey,lo_linenumber,lo_custkey,lo_partkey,lo_suppkey,lo_orderdate,lo_orderpriority, + lo_shippriority,lo_quantity,lo_extendedprice,lo_ordtotalprice,lo_discount, + lo_revenue,lo_supplycost,lo_tax,lo_commitdate,lo_shipmode,lo_dummy""", 600572, "lo_orderkey", 481137], "part": ["""p_partkey,p_name,p_mfgr,p_category,p_brand,p_color,p_type,p_size,p_container,p_dummy""", 20000, "p_partkey", 10000], "date": ["""d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, + d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, + d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,d_dummy""", 255, "d_datekey", 224], "supplier": ["""s_suppkey,s_name,s_address,s_city,s_nation,s_region,s_phone,s_dummy""", 200, "s_suppkey", 100]] + + tables.each { tableName, rows -> + sql """ DROP TABLE IF EXISTS $tableName """ + sql new File("""${context.file.parent}/ddl/${tableName}_sequence_create.sql""").text + for (j in 0..<2) { + streamLoad { + table tableName + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', rows[0] + set 'function_column.sequence_col', rows[2] + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + sql 'sync' + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[1]) + } + } + sql """ set delete_without_partition = true; """ + sql new File("""${context.file.parent}/ddl/${tableName}_part_delete.sql""").text + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[3]) + } + streamLoad { + table tableName + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', rows[0] + set 'function_column.sequence_col', rows[2] + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + sql 'sync' + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[1]) + } + } +} diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_one_step.groovy b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_one_step.groovy new file mode 100644 index 0000000000..07ccea1c0f --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_one_step.groovy @@ -0,0 +1,60 @@ +// 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("load_one_step") { + def tables = ["customer": ["""c_custkey,c_name,c_address,c_city,c_nation,c_region,c_phone,c_mktsegment,no_use""", 3000], "lineorder": ["""lo_orderkey,lo_linenumber,lo_custkey,lo_partkey,lo_suppkey,lo_orderdate,lo_orderpriority, + lo_shippriority,lo_quantity,lo_extendedprice,lo_ordtotalprice,lo_discount, + lo_revenue,lo_supplycost,lo_tax,lo_commitdate,lo_shipmode,lo_dummy""", 600572], "part": ["""p_partkey,p_name,p_mfgr,p_category,p_brand,p_color,p_type,p_size,p_container,p_dummy""", 20000], "date": ["""d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, + d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, + d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,d_dummy""", 255], "supplier": ["""s_suppkey,s_name,s_address,s_city,s_nation,s_region,s_phone,s_dummy""", 200]] + + tables.each { tableName, rows -> + sql """ DROP TABLE IF EXISTS $tableName """ + sql new File("""${context.file.parent}/ddl/${tableName}_create.sql""").text + streamLoad { + table tableName + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', rows[0] + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + sql 'sync' + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[1]) + } + } +} diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_three_step.groovy b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_three_step.groovy new file mode 100644 index 0000000000..53e7e6d4dd --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_three_step.groovy @@ -0,0 +1,69 @@ +// 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("load_three_step") { + def tables = ["customer": ["""c_custkey,c_name,c_address,c_city,c_nation,c_region,c_phone,c_mktsegment,no_use""", 3000, "c_custkey"], "lineorder": ["""lo_orderkey,lo_linenumber,lo_custkey,lo_partkey,lo_suppkey,lo_orderdate,lo_orderpriority, + lo_shippriority,lo_quantity,lo_extendedprice,lo_ordtotalprice,lo_discount, + lo_revenue,lo_supplycost,lo_tax,lo_commitdate,lo_shipmode,lo_dummy""", 600572, "lo_orderkey"], "part": ["""p_partkey,p_name,p_mfgr,p_category,p_brand,p_color,p_type,p_size,p_container,p_dummy""", 20000, "p_partkey"], "date": ["""d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, + d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, + d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,d_dummy""", 255, "d_datekey"], "supplier": ["""s_suppkey,s_name,s_address,s_city,s_nation,s_region,s_phone,s_dummy""", 200, "s_suppkey"]] + + tables.each { tableName, rows -> + sql """ DROP TABLE IF EXISTS $tableName """ + sql new File("""${context.file.parent}/ddl/${tableName}_sequence_create.sql""").text + for (j in 0..<2) { + streamLoad { + table tableName + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', rows[0] + set 'function_column.sequence_col', rows[2] + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + sql 'sync' + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[1]) + } + } + sql new File("""${context.file.parent}/ddl/${tableName}_delete.sql""").text + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == 0) + } + } +} diff --git a/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_two_step.groovy b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_two_step.groovy new file mode 100644 index 0000000000..85b2de6480 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_load_zstd_p0/load_two_step.groovy @@ -0,0 +1,67 @@ +// 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("load_two_step") { + def tables = ["customer": ["""c_custkey,c_name,c_address,c_city,c_nation,c_region,c_phone,c_mktsegment,no_use""", 3000, "c_custkey"], "lineorder": ["""lo_orderkey,lo_linenumber,lo_custkey,lo_partkey,lo_suppkey,lo_orderdate,lo_orderpriority, + lo_shippriority,lo_quantity,lo_extendedprice,lo_ordtotalprice,lo_discount, + lo_revenue,lo_supplycost,lo_tax,lo_commitdate,lo_shipmode,lo_dummy""", 600572, "lo_orderkey"], "part": ["""p_partkey,p_name,p_mfgr,p_category,p_brand,p_color,p_type,p_size,p_container,p_dummy""", 20000, "p_partkey"], "date": ["""d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, + d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, + d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,d_dummy""", 255, "d_datekey"], "supplier": ["""s_suppkey,s_name,s_address,s_city,s_nation,s_region,s_phone,s_dummy""", 200, "s_suppkey"]] + + tables.each { tableName, rows -> + sql """ DROP TABLE IF EXISTS $tableName """ + sql new File("""${context.file.parent}/ddl/${tableName}_sequence_create.sql""").text + streamLoad { + table tableName + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', rows[0] + set 'function_column.sequence_col', rows[2] + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + sql 'sync' + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == rows[1]) + } + sql new File("""${context.file.parent}/ddl/${tableName}_delete.sql""").text + for (int i = 1; i <= 5; i++) { + def loadRowCount = sql "select count(1) from ${tableName}" + logger.info("select ${tableName} numbers: ${loadRowCount[0][0]}".toString()) + assertTrue(loadRowCount[0][0] == 0) + } + } +} diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_create.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_create.sql new file mode 100644 index 0000000000..d6566d3f1b --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_create.sql @@ -0,0 +1,17 @@ +CREATE TABLE IF NOT EXISTS `customer` ( + `c_custkey` int(11) NOT NULL COMMENT "", + `c_name` varchar(26) NOT NULL COMMENT "", + `c_address` varchar(41) NOT NULL COMMENT "", + `c_city` varchar(11) NOT NULL COMMENT "", + `c_nation` varchar(16) NOT NULL COMMENT "", + `c_region` varchar(13) NOT NULL COMMENT "", + `c_phone` varchar(16) NOT NULL COMMENT "", + `c_mktsegment` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`c_custkey`) +DISTRIBUTED BY HASH(`c_custkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_delete.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_delete.sql new file mode 100644 index 0000000000..fe22a226fe --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/customer_delete.sql @@ -0,0 +1 @@ +truncate table customer; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_create.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_create.sql new file mode 100644 index 0000000000..d6ad38d8bd --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_create.sql @@ -0,0 +1,26 @@ +CREATE TABLE IF NOT EXISTS `date` ( + `d_datekey` int(11) NOT NULL COMMENT "", + `d_date` varchar(20) NOT NULL COMMENT "", + `d_dayofweek` varchar(10) NOT NULL COMMENT "", + `d_month` varchar(11) NOT NULL COMMENT "", + `d_year` int(11) NOT NULL COMMENT "", + `d_yearmonthnum` int(11) NOT NULL COMMENT "", + `d_yearmonth` varchar(9) NOT NULL COMMENT "", + `d_daynuminweek` int(11) NOT NULL COMMENT "", + `d_daynuminmonth` int(11) NOT NULL COMMENT "", + `d_daynuminyear` int(11) NOT NULL COMMENT "", + `d_monthnuminyear` int(11) NOT NULL COMMENT "", + `d_weeknuminyear` int(11) NOT NULL COMMENT "", + `d_sellingseason` varchar(14) NOT NULL COMMENT "", + `d_lastdayinweekfl` int(11) NOT NULL COMMENT "", + `d_lastdayinmonthfl` int(11) NOT NULL COMMENT "", + `d_holidayfl` int(11) NOT NULL COMMENT "", + `d_weekdayfl` int(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`d_datekey`) +DISTRIBUTED BY HASH(`d_datekey`) BUCKETS 1 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_delete.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_delete.sql new file mode 100644 index 0000000000..12933cbbad --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/date_delete.sql @@ -0,0 +1 @@ +truncate table `date`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_create.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_create.sql new file mode 100644 index 0000000000..44bbfaf804 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_create.sql @@ -0,0 +1,34 @@ +CREATE TABLE IF NOT EXISTS `lineorder` ( + `lo_orderdate` int(11) NOT NULL COMMENT "", + `lo_orderkey` bigint(20) NOT NULL COMMENT "", + `lo_linenumber` bigint(20) NOT NULL COMMENT "", + `lo_custkey` int(11) NOT NULL COMMENT "", + `lo_partkey` int(11) NOT NULL COMMENT "", + `lo_suppkey` int(11) NOT NULL COMMENT "", + `lo_orderpriority` varchar(16) NOT NULL COMMENT "", + `lo_shippriority` int(11) NOT NULL COMMENT "", + `lo_quantity` bigint(20) NOT NULL COMMENT "", + `lo_extendedprice` bigint(20) NOT NULL COMMENT "", + `lo_ordtotalprice` bigint(20) NOT NULL COMMENT "", + `lo_discount` bigint(20) NOT NULL COMMENT "", + `lo_revenue` bigint(20) NOT NULL COMMENT "", + `lo_supplycost` bigint(20) NOT NULL COMMENT "", + `lo_tax` bigint(20) NOT NULL COMMENT "", + `lo_commitdate` bigint(20) NOT NULL COMMENT "", + `lo_shipmode` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`lo_orderdate`,`lo_orderkey`,`lo_linenumber`) +PARTITION BY RANGE(`lo_orderdate`) +(PARTITION p1992 VALUES [("-2147483648"), ("19930101")), +PARTITION p1993 VALUES [("19930101"), ("19940101")), +PARTITION p1994 VALUES [("19940101"), ("19950101")), +PARTITION p1995 VALUES [("19950101"), ("19960101")), +PARTITION p1996 VALUES [("19960101"), ("19970101")), +PARTITION p1997 VALUES [("19970101"), ("19980101")), +PARTITION p1998 VALUES [("19980101"), ("19990101"))) +DISTRIBUTED BY HASH(`lo_orderkey`) BUCKETS 48 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_delete.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_delete.sql new file mode 100644 index 0000000000..329e040060 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/lineorder_delete.sql @@ -0,0 +1 @@ +truncate table lineorder; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_create.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_create.sql new file mode 100644 index 0000000000..0c6f6e371a --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_create.sql @@ -0,0 +1,18 @@ +CREATE TABLE IF NOT EXISTS `part` ( + `p_partkey` int(11) NOT NULL COMMENT "", + `p_name` varchar(23) NOT NULL COMMENT "", + `p_mfgr` varchar(7) NOT NULL COMMENT "", + `p_category` varchar(8) NOT NULL COMMENT "", + `p_brand` varchar(10) NOT NULL COMMENT "", + `p_color` varchar(12) NOT NULL COMMENT "", + `p_type` varchar(26) NOT NULL COMMENT "", + `p_size` int(11) NOT NULL COMMENT "", + `p_container` varchar(11) NOT NULL COMMENT "" +) +UNIQUE KEY (`p_partkey`) +DISTRIBUTED BY HASH(`p_partkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_delete.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_delete.sql new file mode 100644 index 0000000000..02c6abd253 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/part_delete.sql @@ -0,0 +1 @@ +truncate table `part`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_create.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_create.sql new file mode 100644 index 0000000000..b021767b47 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_create.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS `supplier` ( + `s_suppkey` int(11) NOT NULL COMMENT "", + `s_name` varchar(26) NOT NULL COMMENT "", + `s_address` varchar(26) NOT NULL COMMENT "", + `s_city` varchar(11) NOT NULL COMMENT "", + `s_nation` varchar(16) NOT NULL COMMENT "", + `s_region` varchar(13) NOT NULL COMMENT "", + `s_phone` varchar(16) NOT NULL COMMENT "" +) +UNIQUE KEY (`s_suppkey`) +DISTRIBUTED BY HASH(`s_suppkey`) BUCKETS 10 +PROPERTIES ( +"compression"="zstd", +"replication_num" = "1", +"enable_unique_key_merge_on_write" = "true" +); diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_delete.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_delete.sql new file mode 100644 index 0000000000..39e663134c --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/ddl/supplier_delete.sql @@ -0,0 +1 @@ +truncate table `supplier`; \ No newline at end of file diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/load.groovy b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/load.groovy new file mode 100644 index 0000000000..3d442dc7fe --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/load.groovy @@ -0,0 +1,78 @@ +// 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. + +// Most of the cases are copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases +// and modified by Doris. + +// Note: To filter out tables from sql files, use the following one-liner comamnd +// sed -nr 's/.*tables: (.*)$/\1/gp' /path/to/*.sql | sed -nr 's/,/\n/gp' | sort | uniq +suite("load") { + def tables = ["customer", "lineorder", "part", "date", "supplier"] + def columns = ["""c_custkey,c_name,c_address,c_city,c_nation,c_region,c_phone,c_mktsegment,no_use""", + """lo_orderkey,lo_linenumber,lo_custkey,lo_partkey,lo_suppkey,lo_orderdate,lo_orderpriority, + lo_shippriority,lo_quantity,lo_extendedprice,lo_ordtotalprice,lo_discount, + lo_revenue,lo_supplycost,lo_tax,lo_commitdate,lo_shipmode,lo_dummy""", + """p_partkey,p_name,p_mfgr,p_category,p_brand,p_color,p_type,p_size,p_container,p_dummy""", + """d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, + d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, + d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,d_dummy""", + """s_suppkey,s_name,s_address,s_city,s_nation,s_region,s_phone,s_dummy"""] + + for (String table in tables) { + sql new File("""${context.file.parent}/ddl/${table}_create.sql""").text + sql new File("""${context.file.parent}/ddl/${table}_delete.sql""").text + } + i = 0 + for (String tableName in tables) { + streamLoad { + // a default db 'regression_test' is specified in + // ${DORIS_HOME}/conf/regression-conf.groovy + table tableName + + // default label is UUID: + // set 'label' UUID.randomUUID().toString() + + // default column_separator is specify in doris fe config, usually is '\t'. + // this line change to ',' + set 'column_separator', '|' + set 'compress_type', 'GZ' + set 'columns', columns[i] + // relate to ${DORIS_HOME}/regression-test/data/demo/streamload_input.csv. + // also, you can stream load a http stream, e.g. http://xxx/some.csv + file """${context.sf1DataPath}/ssb/sf0.1/${tableName}.tbl.gz""" + + time 10000 // limit inflight 10s + + // stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(json.NumberTotalRows, json.NumberLoadedRows) + assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) + } + } + i++ + } +} diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.sql new file mode 100644 index 0000000000..4ef15e93ea --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.1.sql @@ -0,0 +1,24 @@ +-- 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. + +SELECT SUM(lo_extendedprice*lo_discount) AS +REVENUE +FROM lineorder, date +WHERE lo_orderdate = d_datekey +AND d_year = 1993 +AND lo_discount BETWEEN 1 AND 3 +AND lo_quantity < 25; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.sql new file mode 100644 index 0000000000..1b8442bd93 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.2.sql @@ -0,0 +1,24 @@ +-- 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. + +SELECT SUM(lo_extendedprice*lo_discount) AS +REVENUE +FROM lineorder, date +WHERE lo_orderdate = d_datekey +AND d_yearmonth = 'Jan1994' +AND lo_discount BETWEEN 4 AND 6 +AND lo_quantity BETWEEN 26 AND 35; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.sql new file mode 100644 index 0000000000..ed6e51b1cf --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q1.3.sql @@ -0,0 +1,25 @@ +-- 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. + +SELECT SUM(lo_extendedprice*lo_discount) AS +REVENUE +FROM lineorder, date +WHERE lo_orderdate = d_datekey +AND d_weeknuminyear= 6 +AND d_year = 1994 +AND lo_discount BETWEEN 5 AND 7 +AND lo_quantity BETWEEN 26 AND 35; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.sql new file mode 100644 index 0000000000..e1a1f52d18 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.1.sql @@ -0,0 +1,26 @@ +-- 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. + +SELECT SUM(lo_revenue), d_year, p_brand +FROM lineorder, date, part, supplier +WHERE lo_orderdate = d_datekey +AND lo_partkey = p_partkey +AND lo_suppkey = s_suppkey +AND p_category = 'MFGR#12' +AND s_region = 'AMERICA' +GROUP BY d_year, p_brand +ORDER BY d_year, p_brand; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.sql new file mode 100644 index 0000000000..3db6170119 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.2.sql @@ -0,0 +1,27 @@ +-- 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. + +SELECT SUM(lo_revenue), d_year, p_brand +FROM lineorder, date, part, supplier +WHERE lo_orderdate = d_datekey +AND lo_partkey = p_partkey +AND lo_suppkey = s_suppkey +AND p_brand BETWEEN 'MFGR#2221' +AND 'MFGR#2228' +AND s_region = 'ASIA' +GROUP BY d_year, p_brand +ORDER BY d_year, p_brand; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.sql new file mode 100644 index 0000000000..b70ca90666 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q2.3.sql @@ -0,0 +1,26 @@ +-- 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. + +SELECT SUM(lo_revenue), d_year, p_brand +FROM lineorder, date, part, supplier +WHERE lo_orderdate = d_datekey +AND lo_partkey = p_partkey +AND lo_suppkey = s_suppkey +AND p_brand = 'MFGR#2239' +AND s_region = 'EUROPE' +GROUP BY d_year, p_brand +ORDER BY d_year, p_brand; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.sql new file mode 100644 index 0000000000..70f17d789b --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.1.sql @@ -0,0 +1,28 @@ +-- 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. + +SELECT c_nation, s_nation, d_year, +SUM(lo_revenue) AS REVENUE +FROM customer, lineorder, supplier, date +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_orderdate = d_datekey +AND c_region = 'ASIA' +AND s_region = 'ASIA' +AND d_year >= 1992 AND d_year <= 1997 +GROUP BY c_nation, s_nation, d_year +ORDER BY d_year ASC, REVENUE DESC; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.sql new file mode 100644 index 0000000000..a416fbea8b --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.2.sql @@ -0,0 +1,28 @@ +-- 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. + +SELECT c_city, s_city, d_year, sum(lo_revenue) +AS REVENUE +FROM customer, lineorder, supplier, date +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_orderdate = d_datekey +AND c_nation = 'UNITED STATES' +AND s_nation = 'UNITED STATES' +AND d_year >= 1992 AND d_year <= 1997 +GROUP BY c_city, s_city, d_year +ORDER BY d_year ASC, REVENUE DESC; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.sql new file mode 100644 index 0000000000..98e29b72e7 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.3.sql @@ -0,0 +1,30 @@ +-- 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. + +SELECT c_city, s_city, d_year, SUM(lo_revenue) +AS REVENUE +FROM customer, lineorder, supplier, date +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_orderdate = d_datekey +AND (c_city='UNITED KI1' +OR c_city='UNITED KI5') +AND (s_city='UNITED KI1' +OR s_city='UNITED KI5') +AND d_year >= 1992 AND d_year <= 1997 +GROUP BY c_city, s_city, d_year +ORDER BY d_year ASC, REVENUE DESC; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.sql new file mode 100644 index 0000000000..65fe992ca4 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q3.4.sql @@ -0,0 +1,30 @@ +-- 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. + +SELECT c_city, s_city, d_year, SUM(lo_revenue) +AS REVENUE +FROM customer, lineorder, supplier, date +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_orderdate = d_datekey +AND (c_city='UNITED KI1' +OR c_city='UNITED KI5') +AND (s_city='UNITED KI1' +OR s_city='UNITED KI5') +AND d_yearmonth = 'Dec1997' +GROUP BY c_city, s_city, d_year +ORDER BY d_year ASC, REVENUE DESC; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.sql new file mode 100644 index 0000000000..bdcd730bf9 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.1.sql @@ -0,0 +1,30 @@ +-- 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. + +SELECT d_year, c_nation, +SUM(lo_revenue - lo_supplycost) AS PROFIT +FROM date, customer, supplier, part, lineorder +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_partkey = p_partkey +AND lo_orderdate = d_datekey +AND c_region = 'AMERICA' +AND s_region = 'AMERICA' +AND (p_mfgr = 'MFGR#1' +OR p_mfgr = 'MFGR#2') +GROUP BY d_year, c_nation +ORDER BY d_year, c_nation; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.sql new file mode 100644 index 0000000000..24c82cf682 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.2.sql @@ -0,0 +1,31 @@ +-- 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. + +SELECT d_year, s_nation, p_category, +SUM(lo_revenue - lo_supplycost) AS PROFIT +FROM date, customer, supplier, part, lineorder +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_partkey = p_partkey +AND lo_orderdate = d_datekey +AND c_region = 'AMERICA' +AND s_region = 'AMERICA' +AND (d_year = 1997 OR d_year = 1998) +AND (p_mfgr = 'MFGR#1' +OR p_mfgr = 'MFGR#2') +GROUP BY d_year, s_nation, p_category +ORDER BY d_year, s_nation, p_category; diff --git a/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.sql b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.sql new file mode 100644 index 0000000000..0dcc08bd26 --- /dev/null +++ b/regression-test/suites/primary_key/ssb_unique_sql_zstd_p0/sql/q4.3.sql @@ -0,0 +1,29 @@ +-- 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. + +SELECT d_year, s_city, p_brand, +SUM(lo_revenue - lo_supplycost) AS PROFIT +FROM date, customer, supplier, part, lineorder +WHERE lo_custkey = c_custkey +AND lo_suppkey = s_suppkey +AND lo_partkey = p_partkey +AND lo_orderdate = d_datekey +AND s_nation = 'UNITED STATES' +AND (d_year = 1997 OR d_year = 1998) +AND p_category = 'MFGR#14' +GROUP BY d_year, s_city, p_brand +ORDER BY d_year, s_city, p_brand; diff --git a/regression-test/suites/primary_key/test_primary_key_simple_case.groovy b/regression-test/suites/primary_key/test_primary_key_simple_case.groovy new file mode 100644 index 0000000000..92f41c118e --- /dev/null +++ b/regression-test/suites/primary_key/test_primary_key_simple_case.groovy @@ -0,0 +1,111 @@ +// 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. + +import org.codehaus.groovy.runtime.IOGroovyMethods + +suite("test_primary_key_simple_case") { + def tableName = "primary_key_simple_case" + onFinish { + try_sql("DROP TABLE IF EXISTS ${tableName}") + } + + sql """ DROP TABLE IF EXISTS ${tableName} """ + sql """ + CREATE TABLE ${tableName} ( + `user_id` LARGEINT NOT NULL COMMENT "用户id", + `date` DATE NOT NULL COMMENT "数据灌入日期时间", + `city` VARCHAR(20) COMMENT "用户所在城市", + `age` SMALLINT COMMENT "用户年龄", + `sex` TINYINT COMMENT "用户性别", + `last_visit_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `last_update_date` DATETIME DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次更新时间", + `last_visit_date_not_null` DATETIME NOT NULL DEFAULT "1970-01-01 00:00:00" COMMENT "用户最后一次访问时间", + `cost` BIGINT DEFAULT "0" COMMENT "用户总消费", + `max_dwell_time` INT DEFAULT "0" COMMENT "用户最大停留时间", + `min_dwell_time` INT DEFAULT "99999" COMMENT "用户最小停留时间") + UNIQUE KEY(`user_id`, `date`, `city`, `age`, `sex`) DISTRIBUTED BY HASH(`user_id`) + PROPERTIES ( "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true"); + """ + + sql """ INSERT INTO ${tableName} VALUES + (1, '2017-10-01', 'Beijing', 10, 1, '2020-01-01', '2020-01-01', '2020-01-01', 1, 30, 20) + """ + + sql """ INSERT INTO ${tableName} VALUES + (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', '2020-01-02', 1, 31, 21) + """ + + sql """ INSERT INTO ${tableName} VALUES + (3, '2017-10-01', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2020-01-03', 1, 32, 20) + """ + + sql """ INSERT INTO ${tableName} VALUES + (4, '2017-10-01', 'Beijing', 10, 1, '2020-01-03', '2020-01-03', '2020-01-03', 1, 32, 22) + """ + + sql """ INSERT INTO ${tableName} VALUES + (5, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 20) + """ + + result = sql """ SELECT * FROM ${tableName} t ORDER BY user_id; """ + assertTrue(result.size() == 5) + assertTrue(result[0].size() == 11) + + // insert a duplicate key + sql """ INSERT INTO ${tableName} VALUES + (5, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 21) + """ + result = sql """ SELECT * FROM ${tableName} t ORDER BY user_id; """ + assertTrue(result.size() == 5) + assertTrue(result[4][10] == 21) + + // insert a duplicate key + sql """ INSERT INTO ${tableName} VALUES + (5, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 22) + """ + result = sql """ SELECT * FROM ${tableName} t ORDER BY user_id; """ + assertTrue(result.size() == 5) + logger.info("fuck: " + result.size()) + assertTrue(result[4][10] == 22) + + result = sql """ SELECT * FROM ${tableName} t where user_id = 5; """ + assertTrue(result.size() == 1) + assertTrue(result[0][10] == 22) + + result = sql """ SELECT COUNT(*) FROM ${tableName};""" + assertTrue(result.size() == 1) + assertTrue(result[0][0] == 5) + + // insert a new key + sql """ INSERT INTO ${tableName} VALUES + (6, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 22) + """ + result = sql """ SELECT * FROM ${tableName} t ORDER BY user_id; """ + assertTrue(result.size() == 6) + + // insert batch key + sql """ INSERT INTO ${tableName} VALUES + (7, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 22), + (7, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 23), + (7, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 24), + (7, '2017-10-01', 'Beijing', 10, 1, NULL, NULL, '2020-01-05', 1, 34, 25) + """ + result = sql """ SELECT * FROM ${tableName} t ORDER BY user_id; """ + assertTrue(result.size() == 7) + assertTrue(result[6][10] == 25) +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org