protected static EquivalenceClasses copy(EquivalenceClasses ec) {
      final EquivalenceClasses newEc = new EquivalenceClasses();
      for (Entry<RexTableInputRef, Set<RexTableInputRef>> e : ec.nodeToEquivalenceClass.entrySet()) {
        newEc.nodeToEquivalenceClass.put(e.getKey(), Sets.newLinkedHashSet(e.getValue()));
      }
      for (Entry<Pair<RexTableInputRef, RexTableInputRef>, Collection<RexCall>> e : ec.equivalenceToOriginalNode.asMap().entrySet()) {
        newEc.equivalenceToOriginalNode.putAll(e.getKey(), e.getValue());
      }
      return newEc;
    }
Class representing an equivalence class, i.e., a set of equivalent columns

TODO: This is a subset of a private class in materialized view rewriting
in Calcite. It should be moved to its own class in Calcite so it can be
accessible here.
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveRelOptUtil.java