-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-20767][table planner] Support filter push down on nested fields #23313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2583185 to
bc31ebd
Compare
|
@flinkbot run azure |
fe34258 to
74ccf82
Compare
|
@wuchong @swuferhong @JingsongLi @becketqin please review |
|
Also tagging @slinkydeveloper |
swuferhong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, @venkata91 . Thanks for your contribution. The PR looks good in general. I left some comments.
...-common/src/main/java/org/apache/flink/table/expressions/NestedFieldReferenceExpression.java
Show resolved
Hide resolved
...-common/src/main/java/org/apache/flink/table/expressions/NestedFieldReferenceExpression.java
Outdated
Show resolved
Hide resolved
...able-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/RexNodeExtractor.scala
Outdated
Show resolved
Hide resolved
...org/apache/flink/table/planner/plan/rules/logical/PushFilterIntoTableSourceScanRuleTest.java
Show resolved
Hide resolved
| util.verifyRelPlan( | ||
| "SELECT id FROM NestedTable WHERE `deepNestedWith.`.nested.```name` = 'foo'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small question, is this the standard way of adding "`"? I couldn't find the relevant documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests the case where the column name has backtick () in it and should be escaped as the whole nested field expression name itself has to be wrapped inside backticks. File formats like ORC etc requires the entire nested field to be with in backticks ()
becketqin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@venkata91 Thanks for the patch. LGTM overall. I agree with @swuferhong that we need to add some IT cases for E2E test.
...able-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/RexNodeExtractor.scala
Show resolved
Hide resolved
|
@becketqin @swuferhong Addressed review comments mainly adding ITCases. |
lsyldliu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@venkata91 Thanks for your contribution, please use git rebase instead of git merge. I can't get your all commits correctly when pull your pr to local.
@lsyldliu Do you want me to fix it? |
I used to use rebase before. But with |
- Implement nested fields filter push down 1. See if a new ResolvedExpression called NestedFieldReferenceExpression has to be implemented or not. If implemented, convert the NestedFieldReferenceExpression in to RexFieldAccess 2. Revisit ExpressionConverter to see if the FieldReferenceExpression has to be converted to a RexFieldAccess 3. Add more tests 4. Check other rules like PushFilterInCalcIntoTableSourceScanRule, PushPartitionIntoTableSourceScanRule
48b49b2 to
dbd3cdf
Compare
nvm, fixed it as requested. |
|
@swuferhong @becketqin @lsyldliu Gentle ping for reviews. |
becketqin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor comment regarding the usage of Optional.
Ping @swuferhong for a review as well.
...e-planner/src/test/java/org/apache/flink/table/planner/factories/TestValuesTableFactory.java
Outdated
Show resolved
Hide resolved
dbd3cdf to
8924b93
Compare
swuferhong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 LGTM
|
Merged to master: 5be4688 |
What is the purpose of the change
Support filter push down on nested fields
For example:
SELECT * FROM users WHERE user.age > 18In the above SQL,
user.age > 18filter can be pushed to table source to avoid scanning records that don't match the predicate. This is especially useful in analytics with columnar formats as well as in JDBC datasources.Brief change log
ResolvedExpressioncalledNestedFieldReferenceExpressionto handle filters on nested fieldsRexNodeToExpressionConverterandExpressionConverterto convertRexFieldAccess<=>NestedFieldReferenceExpressionand vice versa.Verifying this change
Added unit tests in
PushFilterIntoTableSourceScanRuleTestDoes this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation