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

Duplication between AlterView and CreateView #712

Open
ted-johnson opened this issue Nov 14, 2018 · 0 comments
Open

Duplication between AlterView and CreateView #712

ted-johnson opened this issue Nov 14, 2018 · 0 comments

Comments

@ted-johnson
Copy link
Contributor

@ted-johnson ted-johnson commented Nov 14, 2018

This is an issue that I noticed adding Teradata's REPLACE VIEW syntax, as I had to decide between putting it in the CreateView or the AlterView objects.

CreateView has the syntax
CREATE [OR REPLACE] VIEW
while AlterView has the syntax (after my modification)
(ALTER | REPLACE) VIEW

Since view replacement is part of CreateView, it has a meaning that is duplicated with AlterView.
Most SQL syntaxes, e.g.

Teradata
https://docs.teradata.com/reader/VrFCOAaniAIfrJsA51oQJA/70Hc7UuiM6I9L~07Nkr6YQ
SQL Server
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-2017
https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-view-transact-sql?view=sql-server-2017
mysql
https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact-sql?view=sql-server-2017
https://dev.mysql.com/doc/refman/8.0/en/alter-view.html

have a syntax which is identical after the prefix tokens.
Therefore, any change to CreateView must be propagated to AlterView, and vice versa, to keep them in sync.

I see that the CreateView syntax supports a WITH clause, this seems to be from SQL Server.
But in SQL Server, ALTER VIEW can also have a WITH clause.
So the syntax support for CREATE/ALTER VIEW has already diverged.

There are two possible solutions.

  1. Drop the AlterView object, and merge its parsing into CreateView
  2. Add comments with explicit warnings in the CreateView and AlterView object definitions, .jjt parse code, and deparser code that the codepaths for the two statements must be kept in manual sync.

Option 2 is preferable if you think that CREATE VIEW / ALTER VIEW can have significant;y different syntax in future updates, for example Cloudera:
https://www.cloudera.com/documentation/enterprise/5-14-x/topics/impala_alter_view.html
https://www.cloudera.com/documentation/enterprise/5-14-x/topics/impala_create_view.html

If you agree, I can implement a pull request with the preferred option (1 or 2, adding WITH support to AlterView).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.