How about this: Change the spec of copy to “Always creates a new object, even if the attributes are the same. This is in case someone later calls #replaceInput on the result. The exception is leaf nodes (those that have no inputs). Copy may return the same object, because there is no danger of replaceInput being called.”
On Dec 14, 2014, at 1:44 AM, Vladimir Sitnikov <[email protected]> wrote: > This makes sense, however then we need to do something with .copy methods. > I believe, it should always create a new copy no matter what the > "input" values are and update javadocs accordingly. > > Note how > org.apache.calcite.sql2rel.RelDecorrelator#decorrelateRelGeneric > and > org.apache.calcite.sql2rel.RelStructuredTypeFlattener#rewriteGeneric > both use the following dubious approach: > 1) RelNode newRel = rel.copy(rel.getTraitSet(), rel.getInputs()); > 2) newRel.replaceInput(...) > It looks like the intention was to keep the original rel intact, > however it fails if the .copy() is a no-op. > > Vladimir
