-
Notifications
You must be signed in to change notification settings - Fork 1k
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
test: don't allow FK-outer joins and add QTT cases for FK-join with flipped join condition #7526
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.
Thanks @mjsax . Comments inline.
@@ -12,6 +12,18 @@ | |||
"message": "Invalid join condition: table-table joins require to join on the primary key of the right input table. Got LEFT_TABLE.ID1 = RIGHT_TABLE.F2." | |||
} | |||
}, | |||
{ | |||
"name": "Should fail on right non-key attribute for inner-join -- revers join condition order", |
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.
I don't think we need copies of these tests with the feature flag disabled. If the purpose of the test is to check that table-table joins are only allowed on primary keys, then tests for that already exist. If the purpose is to check that the behavior does not change if the join condition is flipped, then that belongs in the regular joins.json
file since it's not related to foreign key joins.
I think adding duplicates of all the new FK join tests will unnecessarily blow up this file and create more busywork for us (harder reviews, more work when we ungate the feature flag) than it's worth.
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.
What is your concrete proposal? I think we should have some of those tests, to make sure that the condition is correctly identified even if the join condition is flipped. And yes, we should have corresponding tests in joins.json
in addition.
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.
My concrete proposal is:
- delete all the new tests in this PR that do not have the feature flag enabled
- remove the comments from the copies of the tests with the feature flag enabled about deleting the test when ungating from the feature flag
- remove
- feature flag enabled
from the names of the copies of the tests that have the feature flag enabled
If we're planning to support flipped join conditions out of the box (which it sounds like we are), then we should add positive test coverage to ensure this is properly supported. I will add that into #7528.
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.
I thought about this a little bit. I agree that those this test (and it's "siblings") should not be part of fk-join test. However, joins.json
is very long and hard to keep an overview what we test and what not. Will add table-table-join.json
and move these 10 test over. Want to keep the reverse order as I think we should test that the condition is detected for both cases (and also that we "flip" left/right condition in the error message).
I would hope we can cleanup join.json
eventually, but it's a little tricky to "move" test as we also need to migrate old plans accordingly. Plan tp can dig into this as a follow up.
"properties": { | ||
"ksql.joins.foreign.key.enable": true | ||
}, | ||
"comments": [ |
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.
If you go with my suggestion above to remove the copies of these tests without the feature flag enabled, then we can also remove these comments. When we ungate the feature flag, we'll simply remove the properties
block rather than deleting the test. You can also update the test name to remove the - feature flag enabled
portion now so we don't have to update the test name later when ungating the feature flag.
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.util.KsqlStatementException", | ||
"message": "Invalid join condition: table-table joins require to join on the primary key of the right input table. Got LEFT_TABLE.ID1 = RIGHT_TABLE.F2." |
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.
I think it'd be marginally better if the error message showed the join expressions in the same order as in the user's query but given the structure of the code right now this is somewhat difficult to achieve so I think this is fine.
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.
I had a similar though... But I think we could fix it: JoinTree could set a flag "flipped" that we preserve that allows us to flip back in the error message. Let me add this.
@@ -193,6 +327,25 @@ | |||
"message": "Invalid join condition: table-table joins require to join on the primary key of the right input table. Got LEFT_TABLE.ID1 = RIGHT_TABLE.F2." | |||
} | |||
}, | |||
{ | |||
"name": "Should fail on right non-key attribute for outer-join (reverse join condition order) - feature flag enabled", |
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 do we need this test? FK joins aren't supported for outer joins at all.
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.
Ah. Good catch. Seems I did to much "blind" c&p :)
@@ -1,99 +1,105 @@ | |||
{ | |||
"tests": [ | |||
{ | |||
"name": "Should fail on right non-key attribute for inner-join", |
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.
This diff is confusion... This test (and the next 3 tests) got moved to table-table-join.json
} | ||
}, | ||
{ | ||
"name": "Should fail on right non-key attribute for inner-join with qualifiers", | ||
"name": "Should fail on outer-join", |
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.
new test
@@ -1,99 +1,105 @@ | |||
{ | |||
"tests": [ | |||
{ | |||
"name": "Should fail on right non-key attribute for inner-join", | |||
"name": "Should fail on left non-key attribute for inner-join", |
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.
existing test, just bad diff
} | ||
}, | ||
{ | ||
"name": "Should fail on right non-key attribute for left-join", | ||
"name": "Should fail on left non-key attribute for inner-join -- revers join condition order", |
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.
new test: duplicates the above existing test.
} | ||
}, | ||
{ | ||
"name": "Should fail on left non-key attribute for inner-join", | ||
"name": "Should fail on left non-key attribute for left-join -- revers join condition order", |
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.
new test: duplicates the above existing test.
], | ||
"expectedException": { | ||
"type": "io.confluent.ksql.util.KsqlStatementException", | ||
"message": "Invalid join condition: foreign-key table-table joins are not supported. Got LEFT_TABLE.F1 = RIGHT_TABLE.ID2." | ||
} | ||
}, | ||
{ | ||
"name": "Should fail on left non-key attribute for outer-join", | ||
"name": "Should fail on left non-key attribute for outer-join -- revers join condition order", |
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.
new test: duplicates the above existing test.
} | ||
}, | ||
{ | ||
"name": "Should fail on right non-key attribute for inner-join with qualifiers", |
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.
This test (and the next tests) got moved to table-table-join.json
} | ||
}, | ||
{ | ||
"name": "Should fail on right non-key attribute for inner-join with alias", | ||
"name": "Should fail on outer-join -- reverse join condition", |
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.
new test (duplicate of the previous new test)
{ | ||
"tests": [ | ||
{ | ||
"name": "Should fail on right non-key attribute for inner-join", |
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.
moved from fk-join.json
} | ||
}, | ||
{ | ||
"name": "Should fail on right non-key attribute for inner-join -- revers join condition order", |
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.
duplicate the test (similar pattern below)
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.
Description
Add a check to disallow OUTER join for FK-joins.
Add new tests for FK-joins with "flipped" join condition. Luckily
JoinTree.build()
take care of the order by callingjoin.flip()
if necessary, and thus we don't need to write additional code for FK-joins for this case. However, we should have the corresponding tests.Testing done
Only added tests for binary joins. Not sure if we should add tests for n-way joins at this point, as don't plan to support n-way joins yet.
Reviewer checklist