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: table alias not found after join #3059

Closed
ukclivecox opened this issue Oct 16, 2024 · 0 comments · Fixed by #3066
Closed

SQL: table alias not found after join #3059

ukclivecox opened this issue Oct 16, 2024 · 0 comments · Fixed by #3066
Assignees
Labels
bug Something isn't working sql

Comments

@ukclivecox
Copy link

Describe the bug

Table aliases can not be used with joined tables in SQL expressions.

To Reproduce

df1 = daft.from_pydict({"idx":[1,2],"val":[10,20]})
df2 = daft.from_pydict({"idx":[1,2],"score":[0.1,0.2]})

df_sql = daft.sql("select * from df1 join df2 on (df1.idx=df2.idx) where df1.val>10").show()

df_sql = daft.sql("select * from df1 join df2 on (df1.idx=df2.idx) where df2.score>0.1").show()

The first sql works and one can use df1.val the second fails with Table not found: df2

Screenshot_2024-10-16_18-14-44

In this case you can use just score but this is not ideal when you have duplicate columns and use of table aliases is normal in SQL expressions to correctly identify the column. I see the core docs discuss duplicate cols after a join are prepended with right. but this would not be ideal or realistic in SQL usage which would not be valid SQL.

Expected behavior

All joined table aliases should be available to be used in the WHERE clause of an SQL expression.

Component(s)

SQL

Additional context

Version 0.3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sql
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants