-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CALCITE-6727] Column uniqueness constrain should only apply to inner… #4088
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add the test?
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -1193,6 +1193,24 @@ private void checkColumnUniquenessForFilterWithConstantColumns(String sql) { | |||
.assertThatUniqueKeysAre(bitSetOf()); | |||
} | |||
|
|||
@Test void testColumnUniquenessForLeftJoinOnLimit1() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the comment. Thanks for your reminder
// 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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this correct even if maxRowCount is 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that the constrain still works even when the build side is empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mihaibudiu Any more thoughts on this? Please take another look when you have a moment
a22211f
to
faa8abe
Compare
In the existing test
the join result column
A.ENAME
is considered to be unique becauseA.EMPNO
is the unique key. The test still passes when the query changes to left join, in which caseA.ENAME
is not guaranteed to be unique.