-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Utilized Columns fix for views #24638
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
Utilized Columns fix for views #24638
Conversation
31a3208 to
682f652
Compare
fd94abe to
6423cf4
Compare
a998a45 to
0ca3ede
Compare
| ImmutableList.of(new ColumnMetadata("a", BIGINT))); | ||
| inSetupTransaction(session -> metadata.createView(session, TPCH_CATALOG, viewMetadata5, viewData5, false)); | ||
|
|
||
| String viewData6 = JsonCodec.jsonCodec(ViewDefinition.class).toJson( |
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.
i know everything else just uses t, v, etc. but can you give these views more descriptive names so it's easier to understand the tests that use them?
| Statement statement = SQL_PARSER.createStatement(query); | ||
| Analysis analysis = analyzer.analyze(statement); | ||
| assertEquals(analysis.getUtilizedTableColumnReferences().values().stream().findFirst().get(), expected); | ||
| assertEquals(analysis.getUtilizedTableColumnReferences().values(), expected); |
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.
can you assert on the whole map (incl. access control info) and not just the values? that way we can be sure it's all correct for definer vs. invoker.
|
Thanks for the release note! Suggest rephrasing to follow the Order of Changes in the Release Notes Guidelines. I adapted phrasing from your Description in the PR, but if you have a better way to phrase it, please do. |
|
|
||
| assertUtilizedTableColumns(query, ImmutableSet.of( | ||
| assertUtilizedTableColumns(query, | ||
| ImmutableMap.of( |
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.
shouldn't definer mode expect 2 different accessControlInfos?
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.
When I ran this, there were 3 access control infos.
AccessControl1: [view_definer1, view_definer2]
AccessControl2: [t1]
AccessControl3: [t13]
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.
I recently changed the test case because I added an equals method to AccessControlContext
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.
For this query, can you give me what the expected result should actually be?
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.
It seems we create a new accessControl when it's definer mode, but not invoker mode
if (owner.isPresent() && !owner.get().equals(session.getIdentity().getUser())) {
// definer mode
identity = new Identity(owner.get(), Optional.empty(), session.getIdentity().getExtraCredentials());
viewAccessControl = new ViewAccessControl(accessControl);
}
else {
identity = session.getIdentity();
viewAccessControl = accessControl;
}
4fb46b7 to
643340d
Compare
| Objects.equals(this.clientInfo, other.clientInfo) && | ||
| Objects.equals(this.clientTags, other.clientTags) && | ||
| Objects.equals(this.source, other.source) && | ||
| Objects.equals(this.queryType, other.queryType); |
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.
Also need to include schema
7aa8b31 to
524ba57
Compare
2f28152 to
da2ea23
Compare
Update test file to check all utilized references Add test for definer mode Lint Untab Untab 2 Remove line break Lint Lint Add cte to view definition Lint Fix naming of test tables Check access control info in tests Remove wrapper set Check ViewAccessControlEquality Refactor test Lint Fix build Update equals method Add check to catalog Add catalog to hashcode Merge unnest
da2ea23 to
d74935c
Compare
|
Needed to fix merge conflict on the test file |
Update test file to check all utilized references Add test for definer mode Lint Untab Untab 2 Remove line break Lint Lint Add cte to view definition Lint Fix naming of test tables Check access control info in tests Remove wrapper set Check ViewAccessControlEquality Refactor test Lint Fix build Update equals method Add check to catalog Add catalog to hashcode Merge unnest
Description
Motivation and Context
T214103298
The user's dataswarm tasks is failing because the ACL is checking every column in the view table when it should only be checking ACL on the utilized columns
Impact
Test Plan
Added automated tests for queries involving views
Deploy to verifier cluster
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.