From ed1824be13ac3921a24c12c5986507a83878b175 Mon Sep 17 00:00:00 2001 From: zy-kkk Date: Mon, 1 Aug 2022 17:47:52 +0800 Subject: [PATCH] add oppo case (#28) --- .../data/usercases/OPPO/sql/q01.out | 4 + .../data/usercases/OPPO/sql/q03.out | 13 ++ .../data/usercases/OPPO/sql/q04.out | 13 ++ .../data/usercases/OPPO/sql/q05.out | 13 ++ .../ads_tag_position_store_distance_all_d.sql | 17 +++ .../suites/usercases/OPPO/load.groovy | 45 +++++++ .../suites/usercases/OPPO/sql/q01.sql | 3 + .../suites/usercases/OPPO/sql/q02.sql | 118 ++++++++++++++++++ .../suites/usercases/OPPO/sql/q03.sql | 21 ++++ .../suites/usercases/OPPO/sql/q04.sql | 10 ++ .../suites/usercases/OPPO/sql/q05.sql | 10 ++ 11 files changed, 267 insertions(+) create mode 100644 regression-test/data/usercases/OPPO/sql/q01.out create mode 100644 regression-test/data/usercases/OPPO/sql/q03.out create mode 100644 regression-test/data/usercases/OPPO/sql/q04.out create mode 100644 regression-test/data/usercases/OPPO/sql/q05.out create mode 100644 regression-test/suites/usercases/OPPO/ddl/ads_tag_position_store_distance_all_d.sql create mode 100644 regression-test/suites/usercases/OPPO/load.groovy create mode 100644 regression-test/suites/usercases/OPPO/sql/q01.sql create mode 100644 regression-test/suites/usercases/OPPO/sql/q02.sql create mode 100644 regression-test/suites/usercases/OPPO/sql/q03.sql create mode 100644 regression-test/suites/usercases/OPPO/sql/q04.sql create mode 100644 regression-test/suites/usercases/OPPO/sql/q05.sql diff --git a/regression-test/data/usercases/OPPO/sql/q01.out b/regression-test/data/usercases/OPPO/sql/q01.out new file mode 100644 index 000000000000000..e1a6562fd0ae096 --- /dev/null +++ b/regression-test/data/usercases/OPPO/sql/q01.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q01 -- +10 1 + diff --git a/regression-test/data/usercases/OPPO/sql/q03.out b/regression-test/data/usercases/OPPO/sql/q03.out new file mode 100644 index 000000000000000..8fbd03b0218561e --- /dev/null +++ b/regression-test/data/usercases/OPPO/sql/q03.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q03 -- +Albania +Azerbaijan +Christmas Island +Cote d'Ivoire +Mexico +Pitcairn Island +Switzerland +Syria +United States Virgin Islands +Uzbekistan + diff --git a/regression-test/data/usercases/OPPO/sql/q04.out b/regression-test/data/usercases/OPPO/sql/q04.out new file mode 100644 index 000000000000000..b3ad0827ff9245f --- /dev/null +++ b/regression-test/data/usercases/OPPO/sql/q04.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q04 -- +\N 0 +Antarctica 1 +Ascension Island 1 +Cook Islands 1 +Equatorial Guinea 1 +Micronesia 1 +Montserrat 1 +Paraguay 1 +Sao Tome and Principe 1 +Saudia Arabia 1 + diff --git a/regression-test/data/usercases/OPPO/sql/q05.out b/regression-test/data/usercases/OPPO/sql/q05.out new file mode 100644 index 000000000000000..13b2b283e80e636 --- /dev/null +++ b/regression-test/data/usercases/OPPO/sql/q05.out @@ -0,0 +1,13 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !q05 -- +Albania Sao Tome and Principe Sao Tome and Principe +Azerbaijan \N \N +Christmas Island Equatorial Guinea Equatorial Guinea +Cote d'Ivoire Ascension Island Ascension Island +Mexico Antarctica Antarctica +Pitcairn Island Micronesia Micronesia +Switzerland Montserrat Montserrat +Syria Saudia Arabia Saudia Arabia +United States Virgin Islands Cook Islands Cook Islands +Uzbekistan Paraguay Paraguay + diff --git a/regression-test/suites/usercases/OPPO/ddl/ads_tag_position_store_distance_all_d.sql b/regression-test/suites/usercases/OPPO/ddl/ads_tag_position_store_distance_all_d.sql new file mode 100644 index 000000000000000..df61e2ecdeb56d3 --- /dev/null +++ b/regression-test/suites/usercases/OPPO/ddl/ads_tag_position_store_distance_all_d.sql @@ -0,0 +1,17 @@ +CREATE TABLE `ads_tag_position_store_distance_all_d` +( + `one_id` varchar(200) NULL COMMENT "oneid", + `dayno` int(11) NULL COMMENT "时间分区", + `imei` varchar(100) NULL COMMENT "imei", + `ssoid` varchar(100) NULL COMMENT "ssoid", + `country_code` varchar(100) NULL COMMENT "国际区号,如+86", + `union_id` varchar(100) NULL COMMENT "union id", + `union_id_dic_id` bigint(20) NULL COMMENT "union_id生成的字典ID", + `ext` varchar(100) NULL COMMENT "拓展字段", + `etl_time` varchar(100) NULL COMMENT "时间戳" +) ENGINE=OLAP +DUPLICATE KEY(`one_id`) +DISTRIBUTED BY HASH(`one_id`) BUCKETS 12 +PROPERTIES ( +"replication_num" = "1" +); \ No newline at end of file diff --git a/regression-test/suites/usercases/OPPO/load.groovy b/regression-test/suites/usercases/OPPO/load.groovy new file mode 100644 index 000000000000000..9e781cc1dcfe3a9 --- /dev/null +++ b/regression-test/suites/usercases/OPPO/load.groovy @@ -0,0 +1,45 @@ +// 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. + +// The cases is copied from https://github.com/trinodb/trino/tree/master +// /testing/trino-product-tests/src/main/resources/sql-tests/testcases/tpcds +// and modified by Doris. +suite("load") { + def tables = + [ + "ads_tag_position_store_distance_all_d" + ] + for (String table in tables) { + sql """DROP TABLE IF EXISTS ${table}""" + sql new File("""${context.file.parent}/ddl/${table}.sql""").text + } + + sql """ + INSERT INTO ads_tag_position_store_distance_all_d (one_id,dayno,imei,ssoid,country_code,union_id,union_id_dic_id,ext,etl_time) VALUES + ('Central African Republic',7,'Switzerland','Mozambique','Montserrat','Algeria',6,'Iraq','Malta'), + ('Russia',7,'Albania','Greenland','Sao Tome and Principe','Saint Martin',1,'Spain','Micronesia'), + ('Saudia Arabia',9,'Pitcairn Island','Georgia','Micronesia','United States of America',10,'Iceland','Georgia'), + ('Sao Tome and Principe',4,'Azerbaijan','Guinea',NULL,'Portugal',1,'Angola','Libya'), + ('Afghanistan',3,'United States Virgin Islands','Kyrgyzstan','Cook Islands','Western Sahara',6,'Turkey','Timor-Leste'), + ('Bahamas',8,'Christmas Island','Moldova','Equatorial Guinea','Sweden',8,'Senegal','Eritrea'), + ('Botswana',6,'Syria','Tunisia','Saudia Arabia','Czech Republic',9,'France','US Minor Outlying Islands'), + ('Senegal',4,'Cote d''Ivoire','Estonia','Ascension Island','Fiji',10,'Myanmar','Bouvet Island'), + ('Syria',4,'Uzbekistan','Dominican Republic','Paraguay','Guam',1,'French Polynesia','Malaysia'), + ('Haiti',6,'Mexico','Seychelles','Antarctica','Hungary',2,'Bangladesh','Saint Lucia'); + """ +} + diff --git a/regression-test/suites/usercases/OPPO/sql/q01.sql b/regression-test/suites/usercases/OPPO/sql/q01.sql new file mode 100644 index 000000000000000..b96105fe4d22829 --- /dev/null +++ b/regression-test/suites/usercases/OPPO/sql/q01.sql @@ -0,0 +1,3 @@ +select union_id_dic_id, ROW_NUMBER() OVER (order by union_id_dic_id) as rownum +from ads_tag_position_store_distance_all_d +where dayno = (select max(dayno) from ads_tag_position_store_distance_all_d); \ No newline at end of file diff --git a/regression-test/suites/usercases/OPPO/sql/q02.sql b/regression-test/suites/usercases/OPPO/sql/q02.sql new file mode 100644 index 000000000000000..600fec71403efaf --- /dev/null +++ b/regression-test/suites/usercases/OPPO/sql/q02.sql @@ -0,0 +1,118 @@ +-- select +-- bitmap_count(bitmap_and( ( +-- select +-- bitmap_and(( +-- select +-- bitmap_and(( +-- select +-- bitmap_and(( +-- select +-- bitmap_union(to_bitmap(a1.ssoid)) as a1_ssoid +-- from +-- ( +-- select +-- one_id , +-- imei , +-- ssoid , +-- country_code , +-- union_id +-- from +-- ads_tag_position_store_distance_all_d +-- where +-- dayno = ( +-- select +-- max(dayno) +-- from +-- ads_tag_position_store_distance_all_d) +-- ) a1 +-- where +-- a1.ssoid is not null +-- and a1.ssoid != ''), +-- ( +-- select +-- bitmap_union(to_bitmap(a2.ssoid)) as a2_ssoid +-- from +-- ( +-- select +-- one_id , +-- imei , +-- ssoid , +-- country_code , +-- union_id +-- from +-- ads_tag_position_store_distance_all_d +-- where +-- dayno = ( +-- select +-- max(dayno) +-- from +-- ads_tag_position_store_distance_all_d)) a2 +-- where +-- a2.ssoid is not null +-- and a2.ssoid != ''))), +-- ( +-- select +-- bitmap_union(to_bitmap(a3.ssoid)) as a3_ssoid +-- from +-- ( +-- select +-- one_id , +-- imei , +-- ssoid , +-- country_code , +-- union_id +-- from +-- ads_tag_position_store_distance_all_d +-- where +-- dayno = ( +-- select +-- max(dayno) +-- from +-- ads_tag_position_store_distance_all_d)) a3 +-- where +-- a3.ssoid is not null +-- and a3.ssoid != ''))), +-- ( +-- select +-- bitmap_union(to_bitmap(a4.ssoid)) as a4_ssoid +-- from +-- ( +-- select +-- one_id , +-- imei , +-- ssoid , +-- country_code , +-- union_id +-- from +-- ads_tag_position_store_distance_all_d +-- where +-- dayno = ( +-- select +-- max(dayno) +-- from +-- ads_tag_position_store_distance_all_d)) a4 +-- where +-- a4.ssoid is not null +-- and a4.ssoid != ''))), +-- ( +-- select +-- bitmap_union(to_bitmap(a5.ssoid)) as a5_ssoid +-- from +-- ( +-- select +-- one_id , +-- imei , +-- ssoid , +-- country_code , +-- union_id +-- from +-- ads_tag_position_store_distance_all_d +-- where +-- dayno = ( +-- select +-- max(dayno) +-- from +-- ads_tag_position_store_distance_all_d)) a5 +-- where +-- a5.ssoid is not null +-- and a5.ssoid != ''))) \ No newline at end of file diff --git a/regression-test/suites/usercases/OPPO/sql/q03.sql b/regression-test/suites/usercases/OPPO/sql/q03.sql new file mode 100644 index 000000000000000..60ffd977f8913f3 --- /dev/null +++ b/regression-test/suites/usercases/OPPO/sql/q03.sql @@ -0,0 +1,21 @@ +select a1.imei +from (select imei + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a1 + left join (select imei + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a2 + on a1.imei = a2.imei + left join (select imei + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a3 + on a1.imei = a3.imei + left join (select imei + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a4 + on a1.imei = a4.imei +order by imei \ No newline at end of file diff --git a/regression-test/suites/usercases/OPPO/sql/q04.sql b/regression-test/suites/usercases/OPPO/sql/q04.sql new file mode 100644 index 000000000000000..369f9482c788167 --- /dev/null +++ b/regression-test/suites/usercases/OPPO/sql/q04.sql @@ -0,0 +1,10 @@ +select country_code, count(country_code) as cnt +from (select a1.imei, a2.country_code + from (select imei + from ads_tag_position_store_distance_all_d + where imei is not null and imei != '') a1 + left join (select imei,country_code + from ads_tag_position_store_distance_all_d + where imei is not null and imei != '') a2 on a1.imei = a2.imei) t +group by country_code +order by country_code \ No newline at end of file diff --git a/regression-test/suites/usercases/OPPO/sql/q05.sql b/regression-test/suites/usercases/OPPO/sql/q05.sql new file mode 100644 index 000000000000000..b4c39a3015137dc --- /dev/null +++ b/regression-test/suites/usercases/OPPO/sql/q05.sql @@ -0,0 +1,10 @@ +select a1.imei, a1.country_code, a2.country_code +from (select imei, country_code + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a1 + left join (select imei, country_code + from ads_tag_position_store_distance_all_d + where imei is not null + and imei != '') a2 on a1.imei = a2.imei +order by imei limit 100