silundong commented on code in PR #4436:
URL: https://github.com/apache/calcite/pull/4436#discussion_r2174264724
##########
core/src/main/java/org/apache/calcite/plan/volcano/VolcanoPlanner.java:
##########
@@ -843,6 +843,39 @@ public RelSubset getSubsetNonNull(RelNode rel) {
prunedNodes.add(rel);
}
+ /**
+ * Replaces all references to the given old subset with the new subset
+ * in the parent nodes' inputs. This is typically used when a rule
+ * rewrites a subquery or merges subsets, such as replacing a filter
+ * with a join in {@link org.apache.calcite.rel.rules.SubQueryRemoveRule}.
+ *
+ * @param oldSubset The subset to be replaced
+ * @param newSubset The subset to replace with
+ */
+ public void replaceSubset(RelSubset oldSubset, RelSubset newSubset) {
+ if (oldSubset == newSubset) {
+ // Nop.
+ return;
+ }
+
+ for (RelNode parent : oldSubset.getParents()) {
+ List<RelNode> inputs = parent.getInputs();
+ boolean updated = false;
+ for (int i = 0; i < inputs.size(); i++) {
+ RelNode child = inputs.get(i);
+ if (child != oldSubset) {
+ continue;
+ }
+ parent.replaceInput(i, newSubset);
Review Comment:
I think that the input (RelSubset) should not be forcibly changed. If the
physical properties are not satisfied, this is wrong; if the physical
properties are satisfied, this is unnecessary.
IMO, the problem is the imperfect inference of RelNode physical properties
(as described in the jira), not the RelSubset.
--
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]