Hi, It turns out RelNode is mutable: replaceInput, well, replaces input in place. This replaceInput has just 5 usages (and 1 in tests) in Calcite source. Drill does not use replaceInput. Hive uses it a bit: https://github.com/apache/hive/search?utf8=%E2%9C%93&q=replaceInput&type=Code
This mutability makes RelNode.copy() semantics ill-defined. It is not clear if the method is safe to avoid copy or not. I guess we need either go with immutable RelNode or always copy in .copy methods. Any more thoughts on the subject? -- Regards, Vladimir Sitnikov
