Skip to content

feat(query): Add optional column names to create/alter view statement #9715

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

Merged
merged 6 commits into from
Jan 25, 2023

Conversation

johnhaxx7
Copy link
Contributor

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

Add optional column names to create/alter view statement

CREATE VIEW [IF NOT EXISTS] [db.]view_name [(<column>, ...)] AS SELECT query
ALTER VIEW [db.]view_name [(<column>, ...)] AS SELECT query

so that column names can be renamed.

If column names is not empty, the subquery is rewrote to

select * from ({subquery}) {viewname}( names ) 

When we select/describe from the view, it'll parse from the new subquery to ensure we get the right column names.

Thanks to @sundy-li for the idea!

Closes #6854

@vercel
Copy link

vercel bot commented Jan 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated
databend ⬜️ Ignored (Inspect) Jan 25, 2023 at 4:29AM (UTC)

@mergify mergify bot added the pr-feature this PR introduces a new feature to the codebase label Jan 24, 2023
@BohuTANG BohuTANG requested a review from sundy-li January 24, 2023 13:34
@johnhaxx7 johnhaxx7 force-pushed the jhe-view-column-rename branch from cd3c606 to 04b2764 Compare January 24, 2023 13:42
@johnhaxx7 johnhaxx7 requested a review from sundy-li January 25, 2023 04:29
@johnhaxx7
Copy link
Contributor Author

Hi @BohuTANG , seems like I don't have access to merge, can you please help if possible? thanks!

@sundy-li sundy-li merged commit a82c5f7 into databendlabs:main Jan 25, 2023
@johnhaxx7 johnhaxx7 deleted the jhe-view-column-rename branch January 25, 2023 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Make Databend's create view syntax closer to mysql
2 participants