godfreyhe commented on a change in pull request #8468: 
[FLINK-12399][table][table-planner] Fix FilterableTableSource does not change 
after applyPredicate
URL: https://github.com/apache/flink/pull/8468#discussion_r334485078
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/planner/plan/rules/logical/PushProjectIntoTableSourceScanRule.scala
 ##########
 @@ -67,13 +67,23 @@ class PushProjectIntoTableSourceScanRule extends 
RelOptRule(
     val relOptTable = scan.getTable.asInstanceOf[FlinkRelOptTable]
     val tableSourceTable = relOptTable.unwrap(classOf[TableSourceTable[_]])
     val oldTableSource = tableSourceTable.tableSource
-    val newTableSource = oldTableSource match {
+    val (newTableSource, isProjectSuccess) = oldTableSource match {
       case nested: NestedFieldsProjectableTableSource[_] =>
         val nestedFields = RexNodeExtractor.extractRefNestedInputFields(
           project.getProjects, usedFields)
-        nested.projectNestedFields(usedFields, nestedFields)
+        (nested.projectNestedFields(usedFields, nestedFields), true)
       case projecting: ProjectableTableSource[_] =>
-        projecting.projectFields(usedFields)
+        (projecting.projectFields(usedFields), true)
+      case nonProjecting: TableSource[_] =>
+        // projection cannot be pushed to TableSource
+        (nonProjecting, false)
+    }
+
+    if (isProjectSuccess
+      && 
newTableSource.explainSource().equals(oldTableSource.explainSource())) {
 
 Review comment:
   there is a special case: if the query is `select count(*) from 
projectableTableSource`, the `usedFields` to project-pushdown is empty, and the 
table source should keep at least one fields to output to count aggregate. if 
the projectable table has only one filed, the `explainSource` does not change.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to