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: support subquery #750

Open
MingjiHan99 opened this issue Dec 27, 2022 · 2 comments
Open

sql: support subquery #750

MingjiHan99 opened this issue Dec 27, 2022 · 2 comments

Comments

@MingjiHan99
Copy link
Collaborator

MingjiHan99 commented Dec 27, 2022

Step 1: support subquery binding in binder.

Existing binder can only bind columns and tables in the catalog.

One possbile solution is to add new types of column and table bindings: SubqueryColumnRef and SubQueryTableRef.

Step 2: support uncorrlated subquery execution.

Step 3: support subquery execution plan for correlated subquery.

Reference: https://ericfu.me/subquery-optimization/

@MingjiHan99
Copy link
Collaborator Author

@skyzh @wangrunji0408

@wangrunji0408
Copy link
Member

Step 1 is done in #756. Now we support subqueries in FROM clause which can pass TPC-H Q9 #761.
However, TPC-H Q7 still fails because it has one table being joined with itself. The binder will generate the same ColumnRefId for both sides, which actually refer to different subqueries. A possible solution is to decouple ColumnRefId from physical tables, instead generate a temporary table ID for each occurrence.

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