lsyldliu commented on code in PR #22734:
URL: https://github.com/apache/flink/pull/22734#discussion_r1249324747


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/GenerateUtils.scala:
##########
@@ -449,14 +449,17 @@ object GenerateUtils {
    *   whether the input is nullable
    * @param deepCopy
    *   whether to copy the accessed field (usually needed when buffered)
+   * @param fusionCodegen
+   *   if fusion codegen enabled, don't need to hide generated code

Review Comment:
   Giving an example, this is the plan
   ```
   HashJoin(joinType=[InnerJoin], where=[=(a, d)], select=[a, d], build=[right])
   :- Calc(select=[a])
   :  +- HashJoin(joinType=[InnerJoin], where=[=(a, d)], select=[a, d], 
build=[right])
   :     :- Exchange(distribution=[hash[a]])
   :     :  +- Calc(select=[a])
   :     :     +- BoundedStreamScan(table=[[default_catalog, default_database, 
x]], fields=[a, b, c, nx])
   :     +- Exchange(distribution=[hash[d]])
   :        +- Calc(select=[d])
   :           +- BoundedStreamScan(table=[[default_catalog, default_database, 
y]], fields=[d, e, f, ny])
   +- Calc(select=[d])
      +- HashJoin(joinType=[InnerJoin], where=[=(d, a)], select=[d, a], 
build=[right])
         :- Exchange(distribution=[hash[d]])
         :  +- Calc(select=[d])
         :     +- BoundedStreamScan(table=[[default_catalog, default_database, 
y]], fields=[d, e, f, ny])
         +- Exchange(distribution=[hash[a]])
            +- Calc(select=[a])
               +- BoundedStreamScan(table=[[default_catalog, default_database, 
t]], fields=[a, b, c, nt])
   
   ```
   In the Join case, field `a` from the join probe side, and field `d` from the 
build side,  but the downstream join operator only needs to use field `a`, the 
`d` is unnecessary. However, the join operator can't prune the `d` itself, so 
the optimizer inserts a calc operator between two join operators to prune the 
field `d`. In this case, evaluating field `d` is useless, so we can skip it.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to