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

[KYUUBI #5780][AUTHZ] Treating PermanentViewMarker as LeafNode make code simple and got correct privilege object #5781

Closed
wants to merge 10 commits into from

Conversation

AngersZhuuuu
Copy link
Contributor

@AngersZhuuuu AngersZhuuuu commented Nov 27, 2023

🔍 Description

Issue References 🔗

This pull request fixes #5780

Describe Your Solution 🔧

Currently, we convert persist view to PermanentViewMaker, but after optimizer, it changed its child, making it hard to do column prune and get the right column privilege object of persist view.

In this pr, we change PVM as a LeafNode, then we can directly treat it as a HiveRelation since we won't change its internal plan to make code simpler.
But we need to re-optimize the child plan after do privilege check.

Types of changes 🔖

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Test Plan 🧪

Behavior Without This Pull Request ⚰️

For sql such as below table and view

CREATE TABLE IF NOT EXISTS $db1.$table1(id int, scope int);

CREATE TABLE IF NOT EXISTS $db1.$table2(
id int,
name string,
age int,
scope int)
.stripMargin);

CREATE VIEW $db1.$view1
AS
WITH temp AS (
    SELECT max(scope) max_scope
    FROM $db1.$table1)
SELECT id, name, max(scope) as max_scope, sum(age) sum_age
FROM $db1.$table2
WHERE scope in (SELECT max_scope FROM temp)
GROUP BY id, name

When we execute query on $db1.$view1

SELECT id as new_id, name, max_scope FROM $db1.$view1

It will first execute the subquery in the query, then got a un-correct column privilege

Behavior With This Pull Request 🎉

After this change, since PVM is a LeafNode, we won't execute the subquery under PVM, and we directly got the correct column privilege.

Related Unit Tests

Existed UT


Checklists

📝 Author Self Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • This patch was not authored or co-authored using Generative Tooling

📝 Committer Pre-Merge Checklist

  • Pull request title is okay.
  • No license issues.
  • Milestone correctly set?
  • Test coverage is ok
  • Assignees are selected.
  • Minimum number of approvals
  • No changes are requested

Be nice. Be informative.

@AngersZhuuuu
Copy link
Contributor Author

@yaooqinn WDYT about this solution?

@bowenliang123 bowenliang123 changed the title [KYUUBI #5780][AUTHZ] Kyuubi tread PVM ass LeafNode to make logic more simple [KYUUBI #5780][AUTHZ] Simplification by treating PermanentViewMarker as LeafNode Nov 27, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (b920836) 61.42% compared to head (3c18bb7) 61.39%.

Files Patch % Lines
.../authz/rule/RuleEliminatePermanentViewMarker.scala 70.00% 0 Missing and 3 partials ⚠️
...kyuubi/plugin/spark/authz/rule/Authorization.scala 66.66% 0 Missing and 1 partial ⚠️
...authz/rule/permanentview/PermanentViewMarker.scala 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5781      +/-   ##
============================================
- Coverage     61.42%   61.39%   -0.03%     
  Complexity       23       23              
============================================
  Files           607      607              
  Lines         35944    35933      -11     
  Branches       4936     4935       -1     
============================================
- Hits          22079    22062      -17     
- Misses        11478    11486       +8     
+ Partials       2387     2385       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AngersZhuuuu
Copy link
Contributor Author

Any more suggestion?

@yaooqinn
Copy link
Member

please take care of the tests

@AngersZhuuuu
Copy link
Contributor Author

please take care of the tests

Fixed

@AngersZhuuuu
Copy link
Contributor Author

ping @yaooqinn GA passed and conflict resolved.

@yaooqinn yaooqinn added this to the v1.9.0 milestone Nov 29, 2023
@yaooqinn
Copy link
Member

Let's fulfill the PR desc

@yaooqinn
Copy link
Member

The PR title is for refactoring, but actually what we do here is a bugfix, can we make it more precisely.

@AngersZhuuuu AngersZhuuuu changed the title [KYUUBI #5780][AUTHZ] Simplification by treating PermanentViewMarker as LeafNode [KYUUBI #5780][AUTHZ] Treating PermanentViewMarker as LeafNode make code simple and got correct privilege object Nov 29, 2023
@AngersZhuuuu
Copy link
Contributor Author

The PR title is for refactoring, but actually what we do here is a bugfix, can we make it more precisely.

How about current, desc also full fill.

@@ -215,4 +215,4 @@
} ],
"opType" : "SWITCHDATABASE",
"uriDescs" : [ ]
} ]
} ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why this pr needs to change this...But without this change, GA failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yaooqinn yaooqinn closed this in c1685c6 Nov 29, 2023
@yaooqinn
Copy link
Member

Thank you, merged to master

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

Successfully merging this pull request may close these issues.

[TASK][EASY] Authz Treat PVM as leaf node to make it logic more simple
4 participants