mihaibudiu commented on code in PR #4088:
URL: https://github.com/apache/calcite/pull/4088#discussion_r1882454614
##########
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:
it is customary to add a JavaDoc comment to the test indicating the JIRA
issue that is being addressed. This makes it easier for maintainers to
understand the rationale for a test. You can find lots of examples in the code
about how that is supposed to be structured, please follow the pattern.
##########
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:
is this correct even if maxRowCount is 0?
--
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]