Hi, I need a kind of visitor that will be able to rewrite part of relation tree including rex expressions. RexShuttle does a good job when rewriting Rex expressions alone (e.g. calulations, casts, etc).
RelShuttle allows to visit Rel tree (e.g. Project/Filter/etc), however it does not allow to change expressions inside the tree. Here's my question: does anybody object if I add copy(List<RexNode> newChildExps) to AbstractRelNode? The use-case is as follows: when Calcite creates correlated plans, it might reference the same source relation multiple times under different correlation variable names. For instance, here's the sample plan: Correlate(TableScan(A), Filter(b.x=$cor1.x and b.y=$cor2.y, Scan(B))). Latter in the processing, Calcite resolves those $cor1 and $cor2, and I would like to rewrite the tree to make sure the same correlation input is referenced by a single name (e.g. always as $cor1). Currently I use RelShuttle, however I have to manually match LogicalFilter/LogicalProject/LogicalJoin and create some (different!) boiler-plate logic to call the appropriate copy(...) method. -- Vladimir Sitnikov
