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

Add grants support to Streamlit entity #1981

Merged
merged 2 commits into from
Jan 24, 2025
Merged

Conversation

sfc-gh-turbaszek
Copy link
Contributor

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

...

@sfc-gh-astus
Copy link
Contributor

Duplicate #1967 ?

@thomas-lochner
Copy link

Duplicate #1967 ?

#1967 is my PR, please feel free to close in favor of this PR if this offers more capability/scalability.

@sfc-gh-turbaszek sfc-gh-turbaszek force-pushed the add-grants-for-streamlit branch from 242c0ad to b10eef2 Compare January 23, 2025 14:35
@sfc-gh-turbaszek sfc-gh-turbaszek marked this pull request as ready for review January 23, 2025 15:38
@sfc-gh-turbaszek sfc-gh-turbaszek requested review from a team as code owners January 23, 2025 15:38
Comment on lines +257 to +258
for grant in entity_model.grants:
self.execute_query(grant.get_grant_sql(entity_model))
Copy link
Contributor

Choose a reason for hiding this comment

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

Small improvement: execute all grants in single query

@sfc-gh-turbaszek sfc-gh-turbaszek merged commit a22c367 into main Jan 24, 2025
18 checks passed
@sfc-gh-turbaszek sfc-gh-turbaszek deleted the add-grants-for-streamlit branch January 24, 2025 09:50
class GrantBaseModel(UpdatableModel):
grants: Optional[List[Grant]] = Field(title="List of grants", default=None)

def get_grant_sqls(self) -> list[str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add this to StreamlitEntity.get_grant_sql

role: str = Field(title="Role to which the privileges will be granted")

def get_grant_sql(self, entity_model: EntityModelBase) -> str:
return f"GRANT {self.privilege} ON {entity_model.get_type().upper()} {entity_model.fqn.sql_identifier} TO ROLE {self.role}"

Choose a reason for hiding this comment

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

In relation to my PR #1967 , will this allow the ability to grant share privileges on a Streamlit app? It appears Streamlit uses WITH GRANT OPTION to achieve this today.
image

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.

4 participants