Skip to content
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

JOIN conditions are order dependent #777

Closed
seddonm1 opened this issue Jul 26, 2021 · 2 comments · Fixed by #778
Closed

JOIN conditions are order dependent #777

seddonm1 opened this issue Jul 26, 2021 · 2 comments · Fixed by #778
Labels
bug Something isn't working

Comments

@seddonm1
Copy link
Contributor

Describe the bug
Currently the Logical Plan builder assumes that the join conditions fields are provided in the same order as the tables are specified. This is different behavior to how Postgres works which does not care about the order of the tables listed in the condition.

e.g.

t1_id = t2_id works as t1 is left and t1_id comes is on the left:

SELECT t1_id, t1_name, t2_name FROM t1 JOIN t2 ON t1_id = t2_id ORDER BY t1_id;

t2_id = t1_id does not work as t1 is left and t2_id comes from the right table:

SELECT t1_id, t1_name, t2_name FROM t1 JOIN t2 ON t2_id = t1_id ORDER BY t1_id;

To Reproduce
It is easy to reproduce with by changing the test with the first statement to the second statement.

Expected behavior
Postgres does not care which order the join condition fields are listed in as long as they can be uniquely identified.

Additional context
I have create a PR for this.

@seddonm1
Copy link
Contributor Author

@alamb I have added another PR to this to address more cases - could you please re-open?

@houqp houqp reopened this Jul 31, 2021
@seddonm1
Copy link
Contributor Author

seddonm1 commented Sep 5, 2021

closed wtih #797

@seddonm1 seddonm1 closed this as completed Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants