forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dxm's case of join table (apache#140)
# Checklist * 内部Jira:http://39.106.86.136:8090/browse/CIR-1287 * 修复PR: * master: * 1.2-lts: * 1.2-lts: * Doris-master: * [ ] 已修复 * [ ] 未修复 * [x] 无问题 * Doris-1.2-lts: * [ ] 已修复 * [ ] 未修复 * [x] 无问题 * Doris-1.1-lts: * [ ] 已修复 * [ ] 未修复 * [ ] 无问题 --------- Co-authored-by: smallhibiscus <844981280>
- Loading branch information
1 parent
18a59f4
commit 774cb3a
Showing
5 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
regression-test/data/usercases/DXM/sql/test_read_size_error_sql.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !test_read_size_error_sql -- | ||
20221220 10002 123457 80000 \N 0 \N | ||
20221221 10002 123457 80000 \N 0 \N | ||
20221222 10002 123457 80000 \N 0 \N | ||
20221223 10002 123457 80000 \N 0 \N | ||
20221224 10002 123457 80000 \N 0 \N | ||
20221225 10002 123457 80000 \N 0 \N | ||
20221226 10002 123457 80000 \N 0 \N | ||
20221227 10002 123457 80000 \N 0 \N | ||
|
36 changes: 36 additions & 0 deletions
36
regression-test/suites/usercases/DXM/ddl/test_read_size_error_table1.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CREATE TABLE `test_read_size_error_table1` ( | ||
`f_dt` int(11) NOT NULL COMMENT "日期", | ||
`f_key_1` bigint(20) NOT NULL COMMENT "", | ||
`f_key_2` varchar(320) NOT NULL COMMENT "", | ||
`f_value_1` int(11) REPLACE_IF_NOT_NULL NULL COMMENT "", | ||
`f_value_2` int(11) REPLACE_IF_NOT_NULL NULL COMMENT "", | ||
`f_amount_1` bigint(20) REPLACE_IF_NOT_NULL NULL COMMENT "", | ||
`f_amount_2` bigint(20) REPLACE_IF_NOT_NULL NULL COMMENT "" | ||
) ENGINE=OLAP | ||
AGGREGATE KEY(`f_dt`, `f_key_1`, `f_key_2`) | ||
COMMENT "" | ||
PARTITION BY RANGE(`f_dt`) | ||
(PARTITION p202212 VALUES [("20221201"), ("20230101")), | ||
PARTITION p202301 VALUES [("20230101"), ("20230201")), | ||
PARTITION p202302 VALUES [("20230201"), ("20230301")), | ||
PARTITION p202303 VALUES [("20230301"), ("20230401")), | ||
PARTITION p202304 VALUES [("20230401"), ("20230501"))) | ||
DISTRIBUTED BY HASH(`f_key_1`) BUCKETS 32 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"dynamic_partition.enable" = "true", | ||
"dynamic_partition.time_unit" = "MONTH", | ||
"dynamic_partition.time_zone" = "Asia/Shanghai", | ||
"dynamic_partition.start" = "-1200", | ||
"dynamic_partition.end" = "3", | ||
"dynamic_partition.prefix" = "p", | ||
"dynamic_partition.replication_allocation" = "tag.location.default: 1", | ||
"dynamic_partition.buckets" = "32", | ||
"dynamic_partition.create_history_partition" = "false", | ||
"dynamic_partition.history_partition_num" = "-1", | ||
"dynamic_partition.hot_partition_num" = "0", | ||
"dynamic_partition.reserved_history_periods" = "NULL", | ||
"dynamic_partition.start_day_of_month" = "1", | ||
"in_memory" = "false", | ||
"storage_format" = "V2" | ||
); |
13 changes: 13 additions & 0 deletions
13
regression-test/suites/usercases/DXM/ddl/test_read_size_error_table2.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
CREATE TABLE `test_read_size_error_table2` ( | ||
`f_key_1` bigint(20) NOT NULL COMMENT "", | ||
`f_key_2` bigint(20) NOT NULL DEFAULT "0" COMMENT "", | ||
`f_value_1` varchar(128) REPLACE NOT NULL DEFAULT "" COMMENT "" | ||
) ENGINE=OLAP | ||
AGGREGATE KEY(`f_key_1`, `f_key_2`) | ||
COMMENT "OLAP" | ||
DISTRIBUTED BY HASH(`f_key_1`, `f_key_2`) BUCKETS 32 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1", | ||
"in_memory" = "false", | ||
"storage_format" = "V2" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// 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 = | ||
[ | ||
"test_read_size_error_table1", | ||
"test_read_size_error_table2" | ||
] | ||
for (String table in tables) { | ||
sql """DROP TABLE IF EXISTS ${table}""" | ||
sql new File("""${context.file.parent}/ddl/${table}.sql""").text | ||
} | ||
|
||
sql """ | ||
insert into test_read_size_error_table1 values | ||
(20221220, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221221, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221222, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221223, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221224, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221225, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221226, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221227, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221228, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221229, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221230, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20221231, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20230101, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20230102, 123456, '2022122015233522dadv', 10001, 1, 10000, null), | ||
(20230103, 123456, '2022122015233522dadv', 10001, 1, 10000, null),(20221220, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221221, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221222, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221223, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221224, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221225, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221226, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221227, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221228, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221229, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221230, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20221231, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20230101, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20230102, 123457, '2022122015233522dadv', 10002, 1, null, 10000), | ||
(20230103, 123457, '2022122015233522dadv', 10002, 1, null, 10000),(20221220, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221221, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221222, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221223, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221224, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221225, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221226, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221227, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221228, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221229, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221230, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20221231, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20230101, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20230102, 123455, '2022122015233522dadv', 10003, 1, 10000, null), | ||
(20230103, 123455, '2022122015233522dadv', 10003, 1, 10000, null); | ||
""" | ||
|
||
sql """ | ||
insert into test_read_size_error_table2 values | ||
(1, 10001, 'label_1'), | ||
(2, 10002, 'label_1'), | ||
(3, 10003, 'label_1'), | ||
(4, 10001, 'label_2'), | ||
(5, 10002, 'label_2'), | ||
(6, 10003, 'label_2'), | ||
(7, 10003, 'label_3'); | ||
""" | ||
} |
50 changes: 50 additions & 0 deletions
50
regression-test/suites/usercases/DXM/sql/test_read_size_error_sql.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
select | ||
a.f_dt, | ||
a.f_value_1, | ||
a.f_key_1, | ||
a.f_amount_2, | ||
b.f_value_2_char, | ||
ifnull(b.f_amount_1, 0) as f_amount_1, | ||
b.f_value_1 as f_value_1_b | ||
from ( | ||
select | ||
f_dt, | ||
f_value_1, | ||
f_key_1, | ||
sum(f_amount_2) over( | ||
partition by f_key_1,f_value_1 | ||
order by f_key_1,f_value_1 | ||
rows between unbounded preceding and unbounded following | ||
) as f_amount_2 | ||
from test_read_size_error_table1 | ||
where f_dt between 20221220 and 20221227 | ||
and f_amount_2 > 0 | ||
and f_value_1 in ( | ||
select f_key_2 | ||
from test_read_size_error_table2 | ||
where f_value_1 in ('label_1', 'label_2') | ||
) | ||
and f_value_1 not in ( | ||
select f_key_2 | ||
from test_read_size_error_table2 | ||
where f_value_1 in ('label_3', 'label_4') | ||
) | ||
) a | ||
left join ( | ||
select | ||
f_dt, | ||
f_value_1, | ||
f_key_1, | ||
case | ||
when f_value_2 = 1 then 'a' | ||
when f_value_2 = 2 then 'b' | ||
when f_value_2 = 3 then 'c' | ||
when f_value_2 = 4 then 'd' | ||
end as f_value_2_char, | ||
sum(f_amount_1) as f_amount_1 | ||
from test_read_size_error_table1 | ||
where f_dt >= 20221220 | ||
and f_dt < 20230103 | ||
and f_amount_1 > 0 | ||
group by f_dt,f_value_1,f_key_1,f_value_2_char | ||
) b on a.f_key_1 = b.f_key_1 and a.f_dt <= b.f_dt and datediff(b.f_dt, a.f_dt) < 7 order by a.f_dt; |