Skip to content

feat: add grants for BigQuery#5444

Merged
newtonapple merged 4 commits intoddai/grantsfrom
ddai/grants-bigquery
Sep 29, 2025
Merged

feat: add grants for BigQuery#5444
newtonapple merged 4 commits intoddai/grantsfrom
ddai/grants-bigquery

Conversation

@newtonapple
Copy link
Contributor

@newtonapple newtonapple commented Sep 26, 2025

Note:

BigQuery's INFORMATION_SCHEMA only has OBJECT_PRIVILEGES. And it must be queried with project, region location and object_name in the WHERE clause.

Additionally, we are enforcing labels on a grantees: user:, domain:, group:, specialGroup: and will always lower-case grantee identity as they get lower-cased by BigQuery. specialGroup contains allUsers & allAuthenticatedUsers. These are case-sensitive and will always returned with the label sepcialGroup when querying OBJECT_PRIVILEGES.

For more info on BigQuery DCL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-control-language

@newtonapple newtonapple force-pushed the ddai/grants-bigquery branch 6 times, most recently from 836ebb7 to 18424e9 Compare September 27, 2025 23:03
self._connection_pool.set_attribute("session_id", value)

def _get_bq_dataset_location(self, project: str, dataset: str) -> str:
return self._db_call(self.client.get_dataset, dataset_ref=f"{project}.{dataset}").location
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you know if dataset_ref needs to be properly quoted? Or are you assuming the strings passed in will have quotes if needed?

Copy link
Contributor Author

@newtonapple newtonapple Sep 29, 2025

Choose a reason for hiding this comment

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

Yeah, I checked their API. I don't think we need to quote it.

def _get_bq_dataset_location(self, project: str, dataset: str) -> str:
return self._db_call(self.client.get_dataset, dataset_ref=f"{project}.{dataset}").location

def _get_current_grants_config(self, table: exp.Table) -> GrantsConfig:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you override _get_grant_expression instead?

@newtonapple newtonapple merged commit 9106f83 into ddai/grants Sep 29, 2025
20 of 22 checks passed
@newtonapple newtonapple deleted the ddai/grants-bigquery branch September 29, 2025 18:16
newtonapple added a commit that referenced this pull request Sep 29, 2025
Co-authored-by: eakmanrq <6326532+eakmanrq@users.noreply.github.com>
newtonapple added a commit that referenced this pull request Sep 30, 2025
Co-authored-by: eakmanrq <6326532+eakmanrq@users.noreply.github.com>
newtonapple added a commit that referenced this pull request Oct 2, 2025
Co-authored-by: eakmanrq <6326532+eakmanrq@users.noreply.github.com>
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.

2 participants