Skip to content

Commit 4414e9a

Browse files
add test
1 parent 3215de3 commit 4414e9a

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
suite("agg_join_pkfk") {
18+
multi_sql """
19+
SET ignore_shape_nodes='PhysicalDistribute,PhysicalProject';
20+
set disable_join_reorder=true;
21+
drop table if exists customer_test;
22+
CREATE TABLE customer_test (
23+
c_customer_sk INT not null ,
24+
c_first_name VARCHAR(50),
25+
c_last_name VARCHAR(50)
26+
);
27+
drop table if exists store_sales_test;
28+
CREATE TABLE store_sales_test (
29+
ss_customer_sk INT,
30+
d_date DATE
31+
);
32+
33+
INSERT INTO customer_test VALUES (1, 'John', 'Smith');
34+
INSERT INTO customer_test VALUES (2, 'John', 'Smith');
35+
36+
INSERT INTO store_sales_test VALUES (1, '2024-01-01');
37+
INSERT INTO store_sales_test VALUES (2, '2024-01-01');
38+
39+
alter table customer_test add constraint c_pk primary key (c_customer_sk);
40+
alter table store_sales_test add constraint ss_c_fk foreign key (ss_customer_sk) references customer_test(c_customer_sk);
41+
"""
42+
explainAndOrderResult 'not_push_down', """
43+
SELECT DISTINCT c_last_name, c_first_name, d_date
44+
FROM store_sales_test inner join customer_test
45+
on store_sales_test.ss_customer_sk = customer_test.c_customer_sk;
46+
"""
47+
48+
explainAndOrderResult 'push_down', """
49+
SELECT DISTINCT c_first_name,c_customer_sk, d_date
50+
FROM store_sales_test inner join customer_test
51+
on store_sales_test.ss_customer_sk = customer_test.c_customer_sk;
52+
"""
53+
54+
explainAndOrderResult 'push_down_with_count', """
55+
SELECT c_first_name,c_customer_sk, d_date,count(c_customer_sk) from (
56+
select *
57+
FROM store_sales_test inner join customer_test
58+
on store_sales_test.ss_customer_sk = customer_test.c_customer_sk
59+
) t
60+
group by c_first_name,c_customer_sk, d_date;
61+
"""
62+
}

0 commit comments

Comments
 (0)