Skip to content

[CALCITE-6011] Add the planner rule that pushes the Filter past a Window#3439

Closed
LakeShen wants to merge 3 commits intoapache:mainfrom
LakeShen:CALCITE-6011
Closed

[CALCITE-6011] Add the planner rule that pushes the Filter past a Window#3439
LakeShen wants to merge 3 commits intoapache:mainfrom
LakeShen:CALCITE-6011

Conversation

@LakeShen
Copy link
Contributor

@LakeShen LakeShen commented Sep 22, 2023

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

@LakeShen LakeShen force-pushed the CALCITE-6011 branch 2 times, most recently from a48fabb to 21bf0ad Compare October 6, 2023 11:44
@LakeShen LakeShen changed the title [CALCITE-6011] Add the RelRule that pushes the Filter past a Window [CALCITE-6011] Add the planner rule that pushes the Filter past a Window Oct 8, 2023
Copy link
Member

@zabetak zabetak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a couple of minor suggestions/comments and will merge once we agree on those.

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");
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

@LakeShen LakeShen Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense for me,I will take it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed according to your suggestion.

@zabetak zabetak self-assigned this Oct 9, 2023
@LakeShen LakeShen force-pushed the CALCITE-6011 branch 2 times, most recently from 1ca47f5 to 0596122 Compare October 10, 2023 10:29
@LakeShen
Copy link
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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@zabetak zabetak closed this in bdafeec Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants