A command-line tool for visualizing dependencies and managing permissions between BigQuery views
Project description
BigQuery View Analyzer
Description
bigquery-view-analyzer
is a command-line tool for visualizing dependencies and managing permissions between BigQuery views.
To authorize a view, permissions must be granted at a dataset level for every view/table referenced in the view definition. This requirement cascades down to every view that's referenced by the parent view, they too must have permissions granted for every view/table they reference - and so on. This can quickly become difficult to manage if you have many nested views across multiple datasets and/or projects.
bigquery-view-analyzer
automatically resolves these dependencies and applies the relevant permissions to all views and datasets referenced by the parent view.
Installation
$ pip install bigquery-view-analyzer
Usage
$ bqva --help
Example
Given the above datasets and tables in BigQuery, to authorize bqva-demo:dataset_4.shared_view
, the following views would need to be authorized with each of the following datasets:
- Authorized views for
dataset_1
bqva-demo:dataset_3.view_a_b_c_d
- Authorized views for
dataset_2
bqva-demo:dataset_3.view_a_b_c_d
bqva-demo:dataset_1.view_c
- Authorized views for
dataset_3
bqva-demo:dataset_2.view_d
bqva-demo:dataset_4.shared_view
You can easily visualize the above view hierarchy using the bqva tree
command.
# View dependency tree and authorization status for 'bqva-demo:dataset_4.shared_view'
$ bqva tree --status --no-key --view "bqva-demo:dataset_4.shared_view"
bqva-demo:dataset_4.shared_view
└── bqva-demo:dataset_3.view_a_b_c_d (⨯)
├── bqva-demo:dataset_1.table_a (⨯)
├── bqva-demo:dataset_1.table_b (⨯)
├── bqva-demo:dataset_1.view_c (⨯)
│ └── bqva-demo:dataset_2.table_c (⨯)
└── bqva-demo:dataset_2.view_d (⨯)
└── bqva-demo:dataset_3.table_d (⨯)
Permissions can be applied automatically to all datasets referenced by the parent view using the bqva authorize
command.
# Apply all permissions required by 'bqva-demo:dataset_4.shared_view'
$ bqva authorize --view "bqva-demo:dataset_4.shared_view"
bqva-demo:dataset_4.shared_view
└── bqva-demo:dataset_3.view_a_b_c_d (✓)
├── bqva-demo:dataset_1.table_a (✓)
├── bqva-demo:dataset_1.table_b (✓)
├── bqva-demo:dataset_1.view_c (✓)
│ └── bqva-demo:dataset_2.table_c (✓)
└── bqva-demo:dataset_2.view_d (✓)
└── bqva-demo:dataset_3.table_d (✓)
If you want to revoke permissions for a view, you can do that too!
# Revoke all permissions granted to 'bqva-demo:dataset_4.shared_view'
$ bqva revoke --view "bqva-demo:dataset_4.shared_view"
bqva-demo:dataset_4.shared_view
└── bqva-demo:dataset_3.view_a_b_c_d (⨯)
├── bqva-demo:dataset_1.table_a (⨯)
├── bqva-demo:dataset_1.table_b (⨯)
├── bqva-demo:dataset_1.view_c (⨯)
│ └── bqva-demo:dataset_2.table_c (⨯)
└── bqva-demo:dataset_2.view_d (⨯)
└── bqva-demo:dataset_3.table_d (⨯)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for bigquery-view-analyzer-20.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | df83d11c00fa3aebeb5480dcad4530706eeeddf879c8dd5195c68a0afb244f78 |
|
MD5 | e19940be72ae9fea414606dd40a8b8e5 |
|
BLAKE2b-256 | 3146f261584dfdc23f56501ef6b9f2a2fd4c7587934e48e2af61f05072b15613 |
Hashes for bigquery_view_analyzer-20.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f4a673e28a3841436347963832c7315901d5239f96abdf6d6a0bf07c54a7911 |
|
MD5 | 83d56a5e08903172e0f8428245c3a741 |
|
BLAKE2b-256 | 4f79c477ac9491b3ebd01388d0b75983f01b68b0104eb589d4ff933109ab5ba6 |