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

Add ambiguous check when generate join plan #4197

Closed
ygf11 opened this issue Nov 14, 2022 · 1 comment · Fixed by #4258
Closed

Add ambiguous check when generate join plan #4197

ygf11 opened this issue Nov 14, 2022 · 1 comment · Fixed by #4258
Labels
bug Something isn't working

Comments

@ygf11
Copy link
Contributor

ygf11 commented Nov 14, 2022

Describe the bug
For some join sql whose meaning is not clear, datafusion will not throw error.
For example, test0 and test1 both has c0 column.

❯ explain select * from test0 as t0 inner join test0 as t1 on c0 = c0;
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type     | plan                                                                                                                                                                    |
+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| logical_plan  | Projection: t0.c0, t0.c1, t0.c2, t0.c3, t0.c4, t0.c5, t1.c0, t1.c1, t1.c2, t1.c3, t1.c4, t1.c5                                                                          |
|               |   Inner Join: t0.c0 = t1.c0                                                                                                                                             |
|               |     SubqueryAlias: t0                                                                                                                                                   |
|               |       TableScan: test0 projection=[c0, c1, c2, c3, c4, c5]                                                                                                              |
|               |     SubqueryAlias: t1                                                                                                                                                   |
|               |       TableScan: test0 projection=[c0, c1, c2, c3, c4, c5]                                                                                                              |

In PostgreSQL, this will throw an error:

psql -d "$POSTGRES_DB" -h "$POSTGRES_HOST" -p "$POSTGRES_PORT" -U "$POSTGRES_USER" -c "explain select * from test0 as t0 inner join test0 as t1 on c0 = c0;"
ERROR:  column reference "c0" is ambiguous
LINE 1: ...select * from test0 as t0 inner join test0 as t1 on c0 = c0;
                                                               ^

The semantics of this sql is not clear, we need throw exception like PostgreSQL do.

To Reproduce
test0 and test1 both has c0 column.

Then run explain select * from test0 as t0 inner join test0 as t1 on c0 = c0;.

Expected behavior

Additional context

@ygf11 ygf11 added the bug Something isn't working label Nov 14, 2022
@mingmwang
Copy link
Contributor

It is a bug, we should fix it.

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