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

frontend: Support ORDER BY arbitrary column #2124

Closed
Enter-tainer opened this issue Apr 25, 2022 · 2 comments · Fixed by #2329
Closed

frontend: Support ORDER BY arbitrary column #2124

Enter-tainer opened this issue Apr 25, 2022 · 2 comments · Fixed by #2329
Labels
component/frontend Protocol, parsing, binder. type/bug Something isn't working type/enhancement Improvements to existing implementation.

Comments

@Enter-tainer
Copy link
Contributor

Describe the bug

Currently only ORDER BY can only apply to output columns. But actually, it should work with arbitrary columns, take the example from PostgreSQL's document. Column c is not SELECTed, but we can still ORDER BY c.

/* this SHOULD work */
SELECT a, b FROM table1 ORDER BY a + b, c;

To Reproduce

create table t(a int, b int);
dev=> explain select a from t order by b;
ERROR:  Item not found: output column "b"

Expected behavior
Should produce correct execution plan rather than errors.

@Enter-tainer Enter-tainer added type/bug Something isn't working component/frontend Protocol, parsing, binder. type/enhancement Improvements to existing implementation. labels Apr 25, 2022
@skyzh
Copy link
Contributor

skyzh commented Apr 25, 2022

SELECT a, b FROM table1 ORDER BY a + b, c;

This query might need some special care. c will become a hidden column in materialized view, but it's not a row_id as we expected before.

@likg227 likg227 assigned likg227 and unassigned likg227 May 3, 2022
@skyzh
Copy link
Contributor

skyzh commented May 3, 2022

I guess @likg227 can first help us support queries like select a from t order by b; in binder. After that, we can then work on visibility issues like b should not be visible in both MV and batch queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/frontend Protocol, parsing, binder. type/bug Something isn't working type/enhancement Improvements to existing implementation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants