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

[Enhancement] Support is_role_in_session function #32984

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

HangyuanLiu
Copy link
Contributor

@HangyuanLiu HangyuanLiu commented Oct 17, 2023

Fixes #issue

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@HangyuanLiu HangyuanLiu requested a review from a team as a code owner October 17, 2023 13:04
gengjun-git
gengjun-git previously approved these changes Oct 18, 2023
Copy link
Contributor

@nshangyiming nshangyiming left a comment

Choose a reason for hiding this comment

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

comments

@ConstantFunction(name = "is_role_in_session", argTypes = {VARCHAR}, returnType = BOOLEAN)
public static ConstantOperator isRoleInSession(ConstantOperator role) {
AuthorizationMgr manager = GlobalStateMgr.getCurrentState().getAuthorizationMgr();
List<String> roleName = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

roleName -> roleNames, besides using hash set is better i think.

@@ -1326,5 +1331,34 @@ public static ConstantOperator urlExtractParameter(ConstantOperator url, Constan
}
return ConstantOperator.createNull(Type.VARCHAR);
}

private static void getRecursiveRole(AuthorizationMgr manager, List<String> roleName, Long roleId) {
Copy link
Contributor

@nshangyiming nshangyiming Oct 18, 2023

Choose a reason for hiding this comment

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

This is pretty much like protected void getAllPredecessorsInner(long roleId, Set<Long> resultSet) throws PrivilegeException , how about renaming it to getAllPredecessorRoleNames() and put it in AuthorizationMgr, it maybe useful in other situations.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

0.0% 0.0% Coverage
2.0% 2.0% Duplication

@wanpengfei-git
Copy link
Collaborator

[FE Incremental Coverage Report]

😍 pass : 18 / 18 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/privilege/AuthorizationMgr.java 7 7 100.00% []
🔵 com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java 7 7 100.00% []
🔵 com/starrocks/sql/analyzer/ExpressionAnalyzer.java 4 4 100.00% []

@wanpengfei-git
Copy link
Collaborator

[BE Incremental Coverage Report]

😍 pass : 0 / 0 (0%)

@nshangyiming nshangyiming enabled auto-merge (squash) October 19, 2023 16:57
@nshangyiming nshangyiming merged commit b6954d3 into StarRocks:main Oct 20, 2023
43 checks passed
@wanpengfei-git
Copy link
Collaborator

@Mergifyio backport branch-3.2

@github-actions github-actions bot removed the 3.2 label Oct 20, 2023
@wanpengfei-git
Copy link
Collaborator

@Mergifyio backport branch-3.1

@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2023

backport branch-3.2

✅ Backports have been created

@github-actions github-actions bot removed the 3.1 label Oct 20, 2023
@mergify
Copy link
Contributor

mergify bot commented Oct 20, 2023

backport branch-3.1

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
mergify bot pushed a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
HangyuanLiu added a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
HangyuanLiu added a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
HangyuanLiu added a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
wanpengfei-git pushed a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
wanpengfei-git pushed a commit that referenced this pull request Oct 20, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
murphyatwork pushed a commit to murphyatwork/starrocks that referenced this pull request Oct 23, 2023
Signed-off-by: HangyuanLiu <[email protected]>
(cherry picked from commit b6954d3)
Signed-off-by: HangyuanLiu <[email protected]>

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/privilege/AuthorizationMgr.java
#	fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/ScalarOperatorFunctions.java
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.

5 participants