Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Add VIEWs support #858

Merged
erizocosmico merged 22 commits into src-d:feature/views from agarciamontoro:feature.views
Oct 28, 2019
Merged

Conversation

@agarciamontoro
Copy link
Contributor

@agarciamontoro agarciamontoro commented Oct 25, 2019
edited
Loading

This PR adds basic support for VIEWs. In particular:

  • Creation of VIEWs is supported through the syntax CREATE [OR REPLACE} [db_name.]view_name AS select_expr
  • Views are treated as tables, and when using them in a query, the unresolved table node is replaced with the plan analyzed from the definition of the view.

I wanted to publish this PR as it is because it was getting too big, but the following tasks are still pending for a future PR:

  • Add support for DROP VIEW statements.
  • Add support for listing views in SHOW TABLE statements.
  • Add support for permanent storage. Right now the implementation only manages VIEWs created in the same session.
  • Add explicit column naming support.

Fixes #53.

Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
@agarciamontoro agarciamontoro requested a review from a team as a code owner October 25, 2019 10:25
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Trying to make golangcibot happy
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Copy link
Contributor

@erizocosmico erizocosmico left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoah, that was a long read. Good job! Overall it looks really good, just some minor nitpicks to make code more idiomatic and a couple of suggestions and lgtm.

agarciamontoro reacted with laugh emoji
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Before, this function read the string containing all the identifiers *and* the
separators between them, splitting the string afterwards to retrieve the list.
Now, the list of identifiers is built on the go.
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
We can discard the error if it was thrown because the view does not exist. But
we don't know if the Delete function will throw different errors in the
future, so it is safer to discard only the one we are sure about.
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
@erizocosmico erizocosmico requested a review from a team October 25, 2019 14:34
Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure that create view statement can be only executed by users with write permissions.

agarciamontoro reacted with thumbs up emoji
@erizocosmico erizocosmico changed the base branch from master to feature/views October 25, 2019 15:05
Copy link
Contributor

I've changed the base of the PR to feature/views branch. All the views PRs will be merged there and then feature/views to master to avoid having partial functionality in master.

@agarciamontoro the follow up PRs should be made against that branch.

agarciamontoro and ajnavarro reacted with thumbs up emoji

Signed-off-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Copy link
Contributor Author

@ajnavarro

Make sure that create view statement can be only executed by users with write permissions.

Done in a006ec7

ajnavarro reacted with thumbs up emoji

@erizocosmico erizocosmico merged commit b513061 into src-d:feature/views Oct 28, 2019
@agarciamontoro agarciamontoro deleted the feature.views branch October 28, 2019 09:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

3 more reviewers

@erizocosmico erizocosmico erizocosmico approved these changes

@golangcibot golangcibot golangcibot left review comments

@ajnavarro ajnavarro ajnavarro approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /