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_r280569656
##########
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:
I see, makes sense. However, it seems comments are not consistent wrt
behavior. Probably there is not a rule that makes a distinction between 'false'
and 'null' right now, so it is fine. Maybe you can create a follow-up (you can
leave it unassigned) so we can discuss and fix it. I will merge this patch
shortly.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services