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 2019/05/02 15:45:32 UTC

[GitHub] [calcite] jcamachor commented on a change in pull request #1185: [CALCITE-3012] areColumnsUnique for FULL OUTER JOIN could return wrong answer when ignoreNulls is false

jcamachor commented on a change in pull request #1185: [CALCITE-3012] areColumnsUnique for FULL OUTER JOIN could return wrong answer when ignoreNulls is false
URL: https://github.com/apache/calcite/pull/1185#discussion_r280481086
 
 

 ##########
 File path: core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java
 ##########
 @@ -254,6 +255,13 @@ public Boolean areColumnsUnique(Join rel, RelMetadataQuery mq,
     final ImmutableBitSet leftColumns = leftAndRightColumns.left;
     final ImmutableBitSet rightColumns = leftAndRightColumns.right;
 
+    // for FULL OUTER JOIN if columns contain column from both inputs it is not
+    // guranteed that the result will be unique
+    if (!ignoreNulls && rel.getJoinType() == JoinRelType.FULL
+        && leftColumns.cardinality() > 0 && rightColumns.cardinality() > 0) {
+      return false;
+    }
 
 Review comment:
   @vineetgarg02 , in the javadoc it is mentioned:
   ```
      * @return whether the columns are unique, or
      * null if not enough information is available to make that determination
   ```
   In this specific case, you are not sure whether columns are unique or not, hence I believe you should return null.

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


With regards,
Apache Git Services