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

Projection aliases support for SELECT queries #103

Merged
merged 2 commits into from Oct 24, 2020
Merged

Conversation

panarch
Copy link
Member

@panarch panarch commented Oct 24, 2020

Now the result of SELECT query returns both aliases and rows.
Implement support for fetching aliases.

e.g.

SELECT id, name as foo FROM TableA;

The query above provides not only fetched rows, but also it serve aliases like ["id", "foo"].

Change Payload::SELECT from

Payload::SELECT(Vec<Row>)

to

Payload::SELECT {
  aliases: Vec<String>,
  rows: Vec<Row>,
}

resolve #83

@panarch panarch added the enhancement New feature or request label Oct 24, 2020
@panarch panarch self-assigned this Oct 24, 2020
Now SELECT query result returns both aliases & rows.
e.g.
SELECT id as foo, name as bar FROM TableA;
SQL query above will return aliases ["foo", "bar"] and rows.

Change select! macro which is helper for tests to specify aliases
@panarch panarch merged commit b76605f into main Oct 24, 2020
@panarch panarch deleted the projection-aliases branch October 24, 2020 07:27
@panarch
Copy link
Member Author

panarch commented Oct 24, 2020

@willy610 Thanks for reporting this issue, now it works!

@willy610
Copy link

Nice implementation.

I think the public sql programmer in interfacing with the select thinks in terms of columns or labels or similar more than alias.

I think alias is more AST

Could be confusing also because all in the projection does not for sure have any AS NAME but sticks to the column name from a table.

Perhaps labels is preferred??

@panarch
Copy link
Member Author

panarch commented Oct 26, 2020

@willy610 That sounds... great.
I agree of the point you mentiond, alias sounds more.. related to AST, it may not fit to user-side names.

labels sounds good and I'll do work on this soon. thanks!

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

Successfully merging this pull request may close these issues.

Getting SELECT projection aliases
2 participants