简体   繁体   中英

BigQuery - query to find what groups and members of those for a specified dataset or all datasets

I'm incredibly new to BigQuery. I'm on a mission to document who has access to each of our datasets. The manual way of copying and pasting group names and then members of that group into a google sheets document would take a very long time and seems unnecessary. I have to believe there is a way to query a dataset to find this information.

Would anyone have any suggestions for something like this? Select datasetName, group, groupMember, roles from x where datasetName = "myDataSet"

TIA!

Actually, Bigquery doesn't bring any way to approach this via standard/legacy SQL language statements as IAM ( Identity and Access Management ) related information is not promoted/published across Bigquery data volumes, in fact not included in INFORMATION_SCHEMA metadatainventory , thus you can't write a query that simply fetches this data.

In particular, you can use bq command-line tool, this Python binary leverages interaction with Biqquery API , that might give a chance to explore Dataset related information, including the access control entries. Given said this, focusing on bq show command you can write the plain bash loop fetching up the dataset metadata along the particular GCP project:

my_project="<Project_ID>";ds=$(bq ls --project_id=$my_project | awk '{print $1}' | tail +3); for ds in $ds; do bq show $my_project:$ds; done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM