Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3520#discussion_r106603629
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/rules/common/PushFilterIntoTableSourceScanRuleBase.scala
---
@@ -36,36 +43,34 @@ trait PushFilterIntoTableSourceScanRuleBase {
filterableSource: FilterableTableSource[_],
description: String): Unit = {
- if (filterableSource.isFilterPushedDown) {
- // The rule can get triggered again due to the transformed "scan =>
filter"
- // sequence created by the earlier execution of this rule when we
could not
- // push all the conditions into the scan
- return
- }
+ Preconditions.checkArgument(!filterableSource.isFilterPushedDown)
val program = calc.getProgram
+ val functionCatalog = FunctionCatalog.withBuiltIns
val (predicates, unconvertedRexNodes) =
RexProgramExtractor.extractConjunctiveConditions(
program,
call.builder().getRexBuilder,
- tableSourceTable.tableEnv.getFunctionCatalog)
+ functionCatalog)
if (predicates.isEmpty) {
// no condition can be translated to expression
return
}
- val (newTableSource, remainingPredicates) =
filterableSource.applyPredicate(predicates)
- // trying to apply filter push down, set the flag to true no matter
whether
- // we actually push any filters down.
- newTableSource.setFilterPushedDown(true)
+ val remainingPredicates = new util.LinkedList[Expression]()
+ predicates.foreach(e => remainingPredicates.add(e))
+
+ val newTableSource =
filterableSource.applyPredicate(remainingPredicates)
--- End diff --
That was actually one of the reasons for converting the predicate to CNF.
In CNF you can either evaluate a complete term or skip it and let a Calc
evaluate it later. I don't see a case where it would make sense to modify a
conjunctive term but not evaluating it. Of course, the table source could
reorganize the expressions but what would be the purpose of that? IMO, this
could be error prone and introduce bugs.
Do you have a concrete use case in mind, when a `FilterableTableSource`
would modify the expressions that it does not evaluate?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---