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

Use empty parsing context to build view's select in CREATE VIEW statement #2049

Merged
merged 1 commit into from
Feb 19, 2024

Conversation

jepett0
Copy link
Collaborator

@jepett0 jepett0 commented Feb 18, 2024

KIKIMR-20891

CREATE VIEW statement parses (and validates) the select statement saved in the view. It should be parsed in a context isolated from the statements executed before the CREATE VIEW statement (we haven't decided yet on the exact scope of the context of the view's select statement, see KIKIMR-20656). It is pretty obvious that one should be able to execute the following statement in one go ("one go" = one press of a "run" button in YDB UI):

-- create view NecessaryInnerView with (security_invoker = true) as select 1;
-- create view ContextTestingView with (security_invoker = true) as select * from `/local/NecessaryInnerView`; -- where `/local/...` is your cluster name

drop view ContextTestingView;
create view ContextTestingView with (security_invoker = true) as select * from `/local/NecessaryInnerView`;

However, executing both drop view and create view in one go currently produces and error:

DropObject is not yet implemented for intent determination transformer

which indicates that the context of the inner query:

select * from `/local/NecessaryInnerView`

is polluted by the previous:

drop view ContextTestingView;

statement.

This problem is fixed by using an empty parsing context for parsing view's inner select statement during handling of CREATE VIEW statement.

queries in CREATE VIEW statement and for selecting from the views

Preliminary validation is done by adding "query_ast" node to the
builded AST of the CREATE VIEW statement. It does not surve any real
purpose (it is not persisted in the scheme) as of now except early validation of view queries.
Copy link

github-actions bot commented Feb 18, 2024

2024-02-18 12:27:16 UTC Pre-commit check for c3bc79b has started.
2024-02-18 12:27:18 UTC Build linux-x86_64-release-asan is running...
🟢 2024-02-18 12:30:20 UTC Build successful.
2024-02-18 12:30:36 UTC Tests are running...
🔴 2024-02-18 14:15:10 UTC Some tests failed, follow the links below.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14776 14578 0 24 135 39

Copy link

github-actions bot commented Feb 18, 2024

2024-02-18 12:27:46 UTC Pre-commit check for c3bc79b has started.
2024-02-18 12:27:49 UTC Build linux-x86_64-relwithdebinfo is running...
🟢 2024-02-18 12:31:10 UTC Build successful.
2024-02-18 12:31:24 UTC Tests are running...
🔴 2024-02-18 14:16:59 UTC Some tests failed, follow the links below.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
67563 56547 0 3 10979 34

@jepett0 jepett0 marked this pull request as ready for review February 19, 2024 08:05
@jepett0 jepett0 requested a review from a team as a code owner February 19, 2024 08:05
@jepett0 jepett0 requested review from nepal, vitstn and ijon February 19, 2024 08:46
@jepett0 jepett0 merged commit 2582d2f into ydb-platform:main Feb 19, 2024
6 of 8 checks passed
jepett0 added a commit to jepett0/ydb that referenced this pull request Mar 6, 2024
jepett0 added a commit to jepett0/ydb that referenced this pull request Mar 6, 2024
jepett0 added a commit to jepett0/ydb that referenced this pull request Mar 11, 2024
jepett0 added a commit that referenced this pull request Mar 13, 2024
…ment (#2049) (#2595)

Based on: #2049

KIKIMR-20891

CREATE VIEW statement parses (and validates) the select statement saved in the view. It should be parsed in a context isolated from the statements executed before the CREATE VIEW statement (we haven't decided yet on the exact scope of the context of the view's select statement, see [KIKIMR-20656](https://st.yandex-team.ru/KIKIMR-20656)). It is pretty obvious that one should be able to execute the following statement in one go ("one go" = one press of a "run" button in YDB UI):
```sql
-- create view NecessaryInnerView with (security_invoker = true) as select 1;
-- create view ContextTestingView with (security_invoker = true) as select * from `/local/NecessaryInnerView`; -- where `/local/...` is your cluster name

drop view ContextTestingView;
create view ContextTestingView with (security_invoker = true) as select * from `/local/NecessaryInnerView`;
```

However, executing both drop view and create view in one go currently produces and error:
```
DropObject is not yet implemented for intent determination transformer
```
which indicates that the context of the inner query:
```sql
select * from `/local/NecessaryInnerView`
```
is polluted by the previous:
```sql
drop view ContextTestingView;
```
statement.

This problem is fixed by using an empty parsing context for parsing view's inner select statement during handling of CREATE VIEW statement.
@mregrock mregrock mentioned this pull request May 15, 2024
This was referenced Jun 7, 2024
@CyberROFL CyberROFL mentioned this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants