-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[enhance](nereids) add rule MultiDistinctSplit (#45209)
### What problem does this PR solve? Problem Summary: This pr add a rewrite rule, which can do this 2 type of rewrite: 1. This rewrite can greatly improve the execution speed of multiple count(distinct) operations. When 3be, ndv=10000000, the performance can be improved by three to four times. select count(distinct a),count(distinct b),count(distinct c) from t; -> with tmp as (select * from t) select * from (select count(distinct a) from tmp) t1 cross join (select count(distinct b) from tmp) t2 cross join (select count(distinct c) from tmp) t3 2.Before this PR, the following SQL statement would fail to execute due to an error: "The query contains multi count distinct or sum distinct, each can't have multi columns". This PR rewrites this type of SQL statement as follows, making it executable without an error. select count(distinct a,d),count(distinct b,c),count(distinct c) from t; -> with tmp as (select * from t) select * from (select count(distinct a,d) from tmp) t1 cross join (select count(distinct b,c) from tmp) t2 cross join (select count(distinct c) from tmp) t3 ### Release note Support multi count distinct with different parameters
- Loading branch information
1 parent
2254956
commit c28c00a
Showing
19 changed files
with
1,274 additions
and
56 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
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
Oops, something went wrong.