Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(query): add is_role_in_session funciton#19867

Merged
TCeason merged 1 commit into
databendlabs:mainfrom
TCeason:add_role_func
May 15, 2026
Merged

feat(query): add is_role_in_session funciton#19867
TCeason merged 1 commit into
databendlabs:mainfrom
TCeason:add_role_func

Conversation

@TCeason
Copy link
Copy Markdown
Collaborator

@TCeason TCeason commented May 15, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

Add IS_ROLE_IN_SESSION(role) as a SQL sugar function so row access and masking policy expressions can check whether a role is active in the current session.

The function is rewritten during semantic type checking against the session's effective roles. Effective roles follow the existing secondary-role semantics:

  • SET SECONDARY ROLES ALL checks all roles available to the current user.
  • SET SECONDARY ROLES NONE checks only the current role and its related roles.
  • SET SECONDARY ROLES role_name checks the current role plus the specified secondary role and their related roles.

This enables policies to express role-dependent access using active role hierarchy instead of checking only CURRENT_ROLE().

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions Bot added the pr-feature this PR introduces a new feature to the codebase label May 15, 2026
@TCeason TCeason requested a review from zhang2014 May 15, 2026 06:06
@TCeason TCeason added this pull request to the merge queue May 15, 2026
Merged via the queue into databendlabs:main with commit 5685eda May 15, 2026
431 of 444 checks passed
@TCeason TCeason deleted the add_role_func branch May 15, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature this PR introduces a new feature to the codebase

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants