[CALCITE-6011] Add the planner rule that pushes the Filter past a Window#3439
Closed
LakeShen wants to merge 3 commits intoapache:mainfrom
Closed
[CALCITE-6011] Add the planner rule that pushes the Filter past a Window#3439LakeShen wants to merge 3 commits intoapache:mainfrom
LakeShen wants to merge 3 commits intoapache:mainfrom
Conversation
a48fabb to
21bf0ad
Compare
zabetak
approved these changes
Oct 9, 2023
Member
zabetak
left a comment
There was a problem hiding this comment.
LGTM, a couple of minor suggestions/comments and will merge once we agree on those.
core/src/main/java/org/apache/calcite/rel/rules/FilterWindowTransposeRule.java
Show resolved
Hide resolved
core/src/main/java/org/apache/calcite/rel/rules/FilterWindowTransposeRule.java
Show resolved
Hide resolved
Comment on lines
4801
to
4822
| /** Test case for | ||
| * <a href="https://issues.apache.org/jira/browse/CALCITE-6011">[CALCITE-6011] | ||
| * Add the planner rule that pushes the Filter past a Window</a>. */ | ||
| @Test void testPushFilterToWindow() { | ||
| CalciteAssert.hr() | ||
| .query("select * from (select \"deptno\", sum(1) over (partition by \"deptno\"\n" | ||
| + " order by \"empid\" rows between unbounded preceding and current row) as a\n" | ||
| + "from \"hr\".\"emps\")" | ||
| + " where \"deptno\" = 10") | ||
| .explainContains("" | ||
| + "PLAN=EnumerableCalc(expr#0..2=[{inputs}], deptno=[$t1], $1=[$t2])\n" | ||
| + " EnumerableWindow(window#0=[window(partition {1} order by [0] rows between " | ||
| + "UNBOUNDED PRECEDING and CURRENT ROW aggs [SUM($2)])])\n" | ||
| + " EnumerableCalc(expr#0..4=[{inputs}], expr#5=[CAST($t1):INTEGER NOT NULL], " | ||
| + "expr#6=[10], expr#7=[=($t5, $t6)], proj#0..1=[{exprs}], $condition=[$t7])\n" | ||
| + " EnumerableTableScan(table=[[hr, emps]])\n") | ||
| .returnsUnordered( | ||
| "deptno=10; A=1", | ||
| "deptno=10; A=2", | ||
| "deptno=10; A=3"); | ||
| } | ||
|
|
Member
There was a problem hiding this comment.
The new rule is not specific to JDBC so its not appropriate to add it here. For end-to-end tests please favor the .iq files. Consider moving this test to winagg.iq file.
Contributor
Author
There was a problem hiding this comment.
It makes sense for me,I will take it.
Contributor
Author
There was a problem hiding this comment.
Fixed according to your suggestion.
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
Outdated
Show resolved
Hide resolved
1ca47f5 to
0596122
Compare
Contributor
Author
|
Hi @zabetak ,thank you for your review suggestions. I have modified the code according to your suggestions. If you have time, please help me review it again |
0596122 to
f1b3157
Compare
zabetak
reviewed
Oct 26, 2023
2be5788 to
6f290f5
Compare
|
Kudos, SonarCloud Quality Gate passed! |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








This rule try to push the Filter past the Window,if a Filter condition all used columns belong to Window partition columns,then it could be pushed .
More details could see:https://issues.apache.org/jira/browse/CALCITE-6011