YuvalItzchakov edited a comment on pull request #15307:
URL: https://github.com/apache/flink/pull/15307#issuecomment-816019831


   @fsk119 A question about the predicate we added to return a 
`LogicalTableScan` only instead of one wrapped with calc:
   
   ```
           if (originProgram.getProjectList().isEmpty()
                   && extractedPredicates._2.length == 0
                   && result.getRemainingFilters().isEmpty()) {
               call.transformTo(newScan);
               return;
           }
   ```
   
   Wouldn't `getProjectList().isEmpty` just return false most of the time? I 
mean most calcs will have some sort of projection, I think what we need to 
check is the triviality of the Calc without the condition. Something like:
   
   ```java
           RexProgram program = programBuilder.getProgram();
           if (program.isTrivial() 
                   && extractedPredicates._2.length == 0
                   && result.getRemainingFilters().isEmpty()) {
               call.transformTo(newScan);
           } else {
               FlinkLogicalCalc newCalc = FlinkLogicalCalc.create(newScan, 
program);
               call.transformTo(newCalc);
           }
   ```
   
   Meaning, create the new program, see if it's trivial. If so, it means 
there's no condition and the projections are identity and we can just create a 
scan.


-- 
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:
[email protected]


Reply via email to