joeyutong commented on code in PR #4088:
URL: https://github.com/apache/calcite/pull/4088#discussion_r1883164101
##########
core/src/test/java/org/apache/calcite/test/RelMetadataTest.java:
##########
@@ -1193,6 +1193,24 @@ private void
checkColumnUniquenessForFilterWithConstantColumns(String sql) {
.assertThatUniqueKeysAre(bitSetOf());
}
+ @Test void testColumnUniquenessForLeftJoinOnLimit1() {
Review Comment:
Added the comment. Thanks for your reminder
##########
core/src/main/java/org/apache/calcite/rel/metadata/RelMdColumnUniqueness.java:
##########
@@ -321,15 +321,16 @@ public Boolean areColumnsUnique(Intersect rel,
RelMetadataQuery mq,
}
final JoinInfo joinInfo = rel.analyzeCondition();
-
- // Joining with a singleton constrains the keys on the other table
- final Double rightMaxRowCount = mq.getMaxRowCount(right);
- if (rightMaxRowCount != null && rightMaxRowCount <= 1.0) {
- leftColumns = leftColumns.union(joinInfo.leftSet());
- }
- final Double leftMaxRowCount = mq.getMaxRowCount(left);
- if (leftMaxRowCount != null && leftMaxRowCount <= 1.0) {
- rightColumns = rightColumns.union(joinInfo.rightSet());
+ if (rel.getJoinType() == JoinRelType.INNER) {
+ // Joining with a singleton constrains the keys on the other table
+ final Double rightMaxRowCount = mq.getMaxRowCount(right);
+ if (rightMaxRowCount != null && rightMaxRowCount <= 1.0) {
+ leftColumns = leftColumns.union(joinInfo.leftSet());
Review Comment:
It seems to me that the constrain still works even when the build side is
empty
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]