venkata91 opened a new pull request, #4928:
URL: https://github.com/apache/calcite/pull/4928

     ## Jira Link
   
     [CALCITE-7511](https://issues.apache.org/jira/browse/CALCITE-7511)
   
     ## Changes Proposed
   
     `LogicalTableFunctionScan` is missing the `accept(RelShuttle)` override 
that every other logical rel has. Dispatch falls through to
     `AbstractRelNode.accept(RelShuttle)`, where `this` is statically typed as 
`RelNode` — so Java selects `RelShuttle.visit(RelNode)` and never
     `visit(TableFunctionScan)`. A `RelShuttleImpl` subclass that overrides 
`visit(TableFunctionScan)` silently no-ops on `LogicalTableFunctionScan` 
instances.
   
     This PR:
   
     1. Adds the standard `accept(RelShuttle)` override on 
`LogicalTableFunctionScan`, mirroring `LogicalProject`, `LogicalFilter`, 
`LogicalJoin`,
     `LogicalCorrelate`, etc.
     2. Adds a regression test in `RelBuilderTest` that constructs a 
`LogicalTableFunctionScan` via `RelBuilder` and verifies a custom
     `visit(TableFunctionScan)` override is reached.
     3. Updates `SqlHintsConverterTest.HintCollector` to use a proper 
`visit(TableFunctionScan)` override instead of an `instanceof 
TableFunctionScan` branch
     inside `visit(RelNode)`. The branch was a workaround for the bug being 
fixed here; with the fix, dispatch reaches `visit(TableFunctionScan)` directly 
and
     the workaround becomes dead code.
   
     ### Reproduction
   
     ```java
     RelNode root = builder.functionScan(rampFunction, 0, 
builder.literal(3)).build();
     boolean[] visited = {false};
     root.accept(new RelShuttleImpl() {
       @Override public RelNode visit(TableFunctionScan scan) {
         visited[0] = true;
         return super.visit(scan);
       }
     });
     // Expected: visited[0] == true
     // Actual:   visited[0] == false  (without the fix)
     ```
   
     ### Impact
   
     `ProjectCorrelateTransposeRule.RelNodesExprsHandler` uses this dispatch to 
rewrite `$cor0.X` field-access references via a `RexShuttle`. When the right
     input of a `Correlate` contains a `LogicalTableFunctionScan`, the rewrite 
is skipped — stale column indices remain in the scan's `rexCall` after pruning,
     and downstream codegen reads the wrong source field at runtime. This was 
observed in Apache Flink's UNNEST pipeline.
   
     (Replace the zero-width-spaced backticks ``` around the Java block with 
regular triple backticks when pasting.)


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