You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2020/07/20 02:53:54 UTC

[GitHub] [calcite] liyafan82 commented on a change in pull request #2074: [CALCITE-4129] Support deep equality check for RelNode

liyafan82 commented on a change in pull request #2074:
URL: https://github.com/apache/calcite/pull/2074#discussion_r457001684



##########
File path: core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
##########
@@ -409,17 +407,34 @@ public RelOptTable getTable() {
    * @see #digestHash()
    */
   @API(since = "1.24", status = API.Status.EXPERIMENTAL)
-  protected boolean digestEquals(Object obj) {
+  public boolean digestEquals(Object obj) {
     if (this == obj) {
       return true;
     }
     if (this.getClass() != obj.getClass()) {
       return false;
     }
     AbstractRelNode that = (AbstractRelNode) obj;
-    return this.getTraitSet().equals(that.getTraitSet())
-        && this.getDigestItems().equals(that.getDigestItems())
+    boolean result = this.getTraitSet().equals(that.getTraitSet())
         && this.getRowType().equalsSansFieldNames(that.getRowType());
+    if (!result) {
+      return false;
+    }
+    List<Pair<String, Object>> items1 = this.getDigestItems();
+    List<Pair<String, Object>> items2 = that.getDigestItems();
+    if (items1.size() != items2.size()) {
+      return false;
+    }
+    for (int i = 0; result && i < items1.size(); i++) {
+      Pair<String, Object> attr1 = items1.get(i);
+      Pair<String, Object> attr2 = items2.get(i);
+      if (attr1.right instanceof RelNode) {
+        result = ((RelNode) attr1.right).digestEquals(attr2.right);
+      } else {
+        result = attr1.equals(attr2);
+      }

Review comment:
       we should return here, if the result is false?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org