-
Notifications
You must be signed in to change notification settings - Fork 638
Views: if exists / if not exists for DDL #10831
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
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
better SQL unit tests
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
); | ||
ExecuteQuery(session, dropQuery); | ||
// an attempt to drop an already deleted view does not produce an error | ||
ExecuteQuery(session, dropQuery); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need more tests to the following cases:
- DROP VIEW query must fail if there is no such view
- DROP VIEW query must fail if we are attempting to delete view, but it is not a view (topic, table etc)
- DROP VIEW IF EXISTS query must fail if we are attempting to delete view, but it is not a view (topic, table etc)
All these cases should work also for ExecuteQuery calls (not only for ExecuteSchemeQuery) - they are newer API
Also the same cases, but for CREATE type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added all 3 DROP VIEW
tests you mentioned.
As for the CREATE VIEW
, the test that checks that the CREATE VIEW
statement does in fact create a view has already existed, so I haven't added it. However, I have added the other two tests for the CREATE VIEW
statement.
more tests
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
⚪ Test history | Ya make output | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Description
Introduce
IF ...
modifiers for the VIEW DDL to not produce errors if the object already exists / does not exist.Context
We would like VIEW users to be able to batch create views with scripts (which should not produce errors during the execution) like the following one:
However, CREATE OR REPLACE VIEW is a bit harder to implement (it needs to drop the view and recreate it in one transaction + update the server side query cache ☆) than the simple alternative:
☆
Ideally the server side query cache entry for the queries referencing the view-to-be-dropped should be deleted in the same transaction as the view. However, this feature is not easy to implement (see this PR for more info). I suppose the query cache update lag would be less of an issue for the scripts using
DROP VIEW
+CREATE VIEW
rather than a singleCREATE OR REPLACE VIEW
, because the later is expected to be atomic.