fix: Pass reasonForSelect to view identity for definer mode#26724
Merged
kevintang2022 merged 1 commit intoprestodb:masterfrom Jan 13, 2026
Merged
fix: Pass reasonForSelect to view identity for definer mode#26724kevintang2022 merged 1 commit intoprestodb:masterfrom
kevintang2022 merged 1 commit intoprestodb:masterfrom
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates Identity construction in definer-mode and system sessions to pass through additional fields such as empty roles, catalogs, and reasonForSelect, ensuring view and materialized view queries run under a fully populated Identity consistent with the current session/connector identity. Class diagram for Identity usage in definer and system sessionsclassDiagram
class Identity {
- String user
- Optional principal
- Map roles
- Map extraCredentials
- Map catalogProperties
- Optional tenant
- Optional reasonForSelect
- List clientTags
+ Identity(user, principal, roles, extraCredentials, catalogProperties, tenant, reasonForSelect, clientTags)
}
class Session {
- Identity identity
+ Identity getIdentity()
}
class ConnectorIdentity {
- String user
- Optional principal
- Map extraCredentials
- Optional reasonForSelect
+ String getUser()
+ Optional getPrincipal()
+ Map getExtraCredentials()
+ Optional getReasonForSelect()
}
class StatementAnalyzer {
+ Scope processMaterializedView(session, owner, accessControl)
+ RelationType analyzeView(query, name, owner, session, accessControl)
}
class MaterializedViewUtils {
+ static Session buildOwnerSession(session, owner, accessControl)
+ static Identity getOwnerIdentity(owner, session)
}
class SystemConnectorSessionUtil {
+ static Session toSession(transactionHandle, connectorSession)
}
class ViewAccessControl {
+ ViewAccessControl(accessControl)
}
Session --> Identity : has
ConnectorIdentity --> Identity : converted_to
StatementAnalyzer --> Identity : constructs_for_definer_mode
MaterializedViewUtils --> Identity : constructs_owner_identity
SystemConnectorSessionUtil --> Identity : constructs_system_identity
StatementAnalyzer --> ViewAccessControl : uses_in_definer_mode
SystemConnectorSessionUtil --> Session : builds
MaterializedViewUtils --> Session : builds_owner_session
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
c8a5ae0 to
7683f99
Compare
Summary: title Differential Revision: D88055399
7683f99 to
6ab7913
Compare
Contributor
NikhilCollooru
left a comment
There was a problem hiding this comment.
can we add a simple unit test for this ? otherwise changes look good to me
NikhilCollooru
approved these changes
Jan 13, 2026
This was referenced Mar 31, 2026
15 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When initialzing a view identity for definer mode permission checks, the reason for select is passed in as empty. This PR ensures that the same reason for select in the invoker's identity is used.
Motivation and Context
When checking definer mode view permissions, the reason for select is always set to empty, which means that permissions checks for table will contain a reason for select but for the same query, the permission check of the underlying base tables for a definer mode view will always be empty, leading to a mismatch in reason for select.
Impact
No impact on permissions checking behavior. The reason for select will now be made available for use in authorization checks for base tables of a definer mode view.
Test Plan
No impact, and existing tests pass.
Contributor checklist
Release Notes
Please follow release notes guidelines and fill in the release notes below.
Differential Revision: D88055399