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

Unify SQL planning for ORDER BY, HAVING, DISTINCT, etc #10326

Open
alamb opened this issue May 1, 2024 · 3 comments · May be fixed by #14180
Open

Unify SQL planning for ORDER BY, HAVING, DISTINCT, etc #10326

alamb opened this issue May 1, 2024 · 3 comments · May be fixed by #14180
Assignees
Labels
enhancement New feature or request sql SQL Planner

Comments

@alamb
Copy link
Contributor

alamb commented May 1, 2024

Is your feature request related to a problem or challenge?

As @jonahgao points out in #10234:

select x from foo order by y can is covered by add_missing_columns, by blindly adding columns into the descendant projection node. Another issue is that we should not run add_missing_columns for other SetExprs except SELECT.

In #10234 @jonahgao added a more general solution to use the merged schema from the select list and the FROM clause to handle resolving HAVING and set operations

However, both codepaths now exist, which makes for fairly complicated planning process

Describe the solution you'd like

I think that we should handle ORDER BY similarly to HAVING, use the merged schema, add the missing columns directly in the select list, instead of traversing the plan looking for projection node. Their processing logic may be reusable. I agree it might be good to have a broader discussion about this.

@jonahgao in #10234 (comment)

Describe alternatives you've considered

One alternative might be add_missing_columns and using the new order_by_to_sort_expr options added in #10234

Additional context

No response

@lichuang
Copy link

lichuang commented Jan 17, 2025

@alamb Is this issue still on going? If so, let me have a try.

@alamb
Copy link
Contributor Author

alamb commented Jan 17, 2025

👋 @lichuang -- I don't know anyone working on it, but maybe @jonahgao knows of something.

THank you!

@jonahgao
Copy link
Member

I haven't started working on it yet. Feel free to take it. Thanks @lichuang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sql SQL Planner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants