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: performing a join that contains both an explicit, and implicit join fails if trying to select table in aggregation #3562

Open
universalmind303 opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working sql

Comments

@universalmind303
Copy link
Contributor

Describe the bug

So this is very oddly specific, but it is pretty common in a lot of the tpc-ds queries.

select count(tbl_3.val3)
from tbl_1 
join tbl_2 on tbl_1.id = tbl_2.id, tbl_3
where tbl_1.id = tbl_3.id
group by tbl_2.val2

To Reproduce

tbl_1 = daft.from_pydict({
    'id': [1,2,3],
    'val': ['a','b','c']
})

tbl_2 = daft.from_pydict({
    'id': [1,2,4], 
    'val2': ['x','y','z']
})

tbl_3 = daft.from_pydict({
    'id': [1,2,5],
    'val3': ['m','n','o'] 
})

tbl_4 = daft.from_pydict({
    'id': [1,3,6],
    'val4': ['p','q','r']
})
daft.sql("""
select count(tbl_3.val3), tbl_2.val2
from tbl_1 
join tbl_2 on tbl_1.id = tbl_2.id, tbl_3
where tbl_1.id = tbl_3.id
group by tbl_2.val2

""").collect()

results in InvalidSQLException: Table not found: tbl_2

Expected behavior

should have the same output as other sql engines
duckdb:

┌───────────────────┬─────────┐
│ count(tbl_3.val3) │  val2   │
│       int64       │ varchar │
├───────────────────┼─────────┤
│                 1 │ y       │
│                 1 │ x       │
└───────────────────┴─────────┘

Component(s)

SQL

Additional context

No response

@universalmind303 universalmind303 added bug Something isn't working needs triage sql and removed needs triage labels Dec 12, 2024
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

No branches or pull requests

1 participant