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

sql: join with USING doesn't support selecting left or right equality column #12033

Closed
RaduBerinde opened this issue Dec 5, 2016 · 0 comments
Assignees

Comments

@RaduBerinde
Copy link
Member

RaduBerinde commented Dec 5, 2016

When joining with USING, the join planNode outputs only a "coalesced" column for each equality pair. This is incorrect for outer joins if we are specifically selecting a source column.

root@:26257> select * from a;
+---+---+
| k | v |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
(2 rows)
root@:26257> select * from b;
+---+---+
| k | v |
+---+---+
| 3 | 3 |
| 4 | 4 |
+---+---+
(2 rows)
root@:26257> SELECT k, a.k, b.k FROM a FULL JOIN b USING (k);
+---+---+---+
| k | k | k |
+---+---+---+
| 1 | 1 | 1 |
| 2 | 2 | 2 |
| 4 | 4 | 4 |
| 3 | 3 | 3 |
+---+---+---+

The correct answer (verified on PG) should be:

SELECT k, a.k, b.k FROM a FULL OUTER JOIN b USING (k);
 k | k | k 
---+---+---
 1 | 1 |  
 2 | 2 |  
 3 |   | 3
 4 |   | 4
(4 rows)

I think the join node should add the coalesced columns in addition to (not in lieu of) the original columns. The new infrastructure around omitted columns will allow us to avoid calculating any columns we don't need. Also see #12028 which suggests some refactoring which may be related.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants