Skip to content

[PROPOSAL] Add Context-Aware Functions for Apache Polaris #1620

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

singhpk234
Copy link
Contributor

@singhpk234 singhpk234 commented May 19, 2025

About the change

I’d like to propose adding context-aware functions to Apache Polaris so that view definitions can resolve security context on the Polaris side (aka catalog end without depending on engines).

Proposed functions

is_principal('<principal_name>') – returns TRUE if the authenticated principal matches <principal_name>, otherwise FALSE.

is_principal_role('<principal_role_name>') – returns TRUE when <principal_role_name> appears in the principal’s role set.

is_catalog_role('<catalog_role_name>') – analogous check at the catalog-role level.

Why it matters

These predicates make views dynamic. Example:

CREATE VIEW dynamic_vw AS
SELECT *
FROM ns1.layer1_table
WHERE is_principal_role('ANALYST');

When a user whose one of principal roles include ANALYST calls LOAD VIEW, Polaris rewrites the view to

SELECT * FROM ns1.layer1_table WHERE TRUE;

For everyone else the view becomes

SELECT * FROM ns1.layer1_table WHERE FALSE;

The result is better and consistent control of the identity resolution without relying on the engine side changes and giving Polaris more authority in enforcing things.
Note the same can be extrapolated to any Polaris stored entity.

Proof of concept

I’ve put together a quick POC branch:
here ^^^

Prior art

Snowflake context functions : https://docs.snowflake.com/en/sql-reference/functions-context
Databricks Unity Catalog offers a similar mechanism called dynamic views:
https://docs.databricks.com/aws/en/views/dynamic

Next steps

If the community is interested, we can discuss API surface, engine implications, and a roadmap for merging.

@singhpk234 singhpk234 closed this May 29, 2025
@singhpk234 singhpk234 reopened this May 29, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Done in Basic Kanban Board May 29, 2025
@github-project-automation github-project-automation bot moved this from Done to PRs In Progress in Basic Kanban Board May 29, 2025
@singhpk234 singhpk234 closed this May 29, 2025
@github-project-automation github-project-automation bot moved this from PRs In Progress to Done in Basic Kanban Board May 29, 2025
@singhpk234 singhpk234 reopened this May 29, 2025
@github-project-automation github-project-automation bot moved this from Done to PRs In Progress in Basic Kanban Board May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant