Skip to content

Commit

Permalink
add oppo case (apache#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
zy-kkk committed Aug 1, 2022
1 parent 79d0733 commit ed1824b
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 0 deletions.
4 changes: 4 additions & 0 deletions regression-test/data/usercases/OPPO/sql/q01.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !q01 --
10 1

13 changes: 13 additions & 0 deletions regression-test/data/usercases/OPPO/sql/q03.out
Original file line number Diff line number Diff line change
@@ -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

13 changes: 13 additions & 0 deletions regression-test/data/usercases/OPPO/sql/q04.out
Original file line number Diff line number Diff line change
@@ -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

13 changes: 13 additions & 0 deletions regression-test/data/usercases/OPPO/sql/q05.out
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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"
);
45 changes: 45 additions & 0 deletions regression-test/suites/usercases/OPPO/load.groovy
Original file line number Diff line number Diff line change
@@ -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');
"""
}

3 changes: 3 additions & 0 deletions regression-test/suites/usercases/OPPO/sql/q01.sql
Original file line number Diff line number Diff line change
@@ -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);
118 changes: 118 additions & 0 deletions regression-test/suites/usercases/OPPO/sql/q02.sql
Original file line number Diff line number Diff line change
@@ -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 != '')))
21 changes: 21 additions & 0 deletions regression-test/suites/usercases/OPPO/sql/q03.sql
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions regression-test/suites/usercases/OPPO/sql/q04.sql
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions regression-test/suites/usercases/OPPO/sql/q05.sql
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ed1824b

Please sign in to comment.