-
Notifications
You must be signed in to change notification settings - Fork 596
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(optimizer): fix
DistinctAggRule
to correctly handle queries wit…
…h intersected arguments between distinct and non-distincted agg calls (#7688) Fixes #7680. Approved-By: st1page
- Loading branch information
Showing
6 changed files
with
191 additions
and
20 deletions.
There are no files selected for viewing
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
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,29 @@ | ||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
statement ok | ||
create table t (v1 int, v2 int, v3 int); | ||
|
||
statement ok | ||
insert into t values (1, 2, 3), (4, 3, 2), (4, 2, 3), (1, 3, 2); | ||
|
||
query I rowsort | ||
select distinct v1 from t; | ||
---- | ||
1 | ||
4 | ||
|
||
query I | ||
select distinct sum(v1) from t group by v2; | ||
---- | ||
5 | ||
|
||
# v2, v3 can be either 2, 3 or 3, 2 | ||
query I | ||
select distinct on(v1) v2 + v3 from t order by v1; | ||
---- | ||
5 | ||
5 | ||
|
||
statement ok | ||
drop table t |
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,74 @@ | ||
statement ok | ||
SET RW_IMPLICIT_FLUSH TO true; | ||
|
||
statement ok | ||
create table t (v1 int, v2 int, v3 int); | ||
|
||
statement ok | ||
create materialized view mv1 as select count(distinct v1) as c_d_v1 from t; | ||
|
||
statement ok | ||
create materialized view mv2 as select v2, count(distinct v1) as c_d_v1 from t group by v2; | ||
|
||
statement ok | ||
create materialized view mv3 as select v2, count(distinct v1) as c_d_v1, max(v3) as max_v3 from t group by v2; | ||
|
||
statement ok | ||
create materialized view mv4 as select v1, count(distinct v2) as c_d_v2, count(distinct v3) as c_d_v3, max(v2) as max_v2 from t group by v1; | ||
|
||
statement ok | ||
create materialized view mv5 as select v1, count(distinct v2) as c_d_v2, min(distinct v2) as min_d_v2, count(distinct v3) as c_d_v3, max(v3) as max_v3 from t group by v1; | ||
|
||
statement ok | ||
insert into t values (1,2,3), (1,2,4), (5,3,8), (2,4,4); | ||
|
||
query I | ||
select * from mv1; | ||
---- | ||
3 | ||
|
||
query II rowsort | ||
select * from mv2; | ||
---- | ||
2 1 | ||
3 1 | ||
4 1 | ||
|
||
query III rowsort | ||
select * from mv3; | ||
---- | ||
2 1 4 | ||
3 1 8 | ||
4 1 4 | ||
|
||
query IIII rowsort | ||
select * from mv4; | ||
---- | ||
1 1 2 2 | ||
2 1 1 4 | ||
5 1 1 3 | ||
|
||
query IIIII rowsort | ||
select * from mv5; | ||
---- | ||
1 1 2 2 4 | ||
2 1 4 1 4 | ||
5 1 3 1 8 | ||
|
||
statement ok | ||
drop materialized view mv1; | ||
|
||
statement ok | ||
drop materialized view mv2; | ||
|
||
statement ok | ||
drop materialized view mv3; | ||
|
||
statement ok | ||
drop materialized view mv4; | ||
|
||
statement ok | ||
drop materialized view mv5; | ||
|
||
statement ok | ||
drop table t; |
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
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
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