{"id":15060721,"url":"https://github.com/servian/bigquery-view-analyzer","last_synced_at":"2025-06-21T10:08:15.593Z","repository":{"id":34939738,"uuid":"192292428","full_name":"servian/bigquery-view-analyzer","owner":"servian","description":"A command-line tool for managing permissions and dependencies for BigQuery authorized views","archived":false,"fork":false,"pushed_at":"2022-05-21T17:06:18.000Z","size":109,"stargazers_count":91,"open_issues_count":9,"forks_count":15,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-06-21T10:08:00.673Z","etag":null,"topics":["bigquery","google-cloud","iam","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/servian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-17T07:01:46.000Z","updated_at":"2025-03-14T11:14:10.000Z","dependencies_parsed_at":"2022-09-01T06:01:40.762Z","dependency_job_id":null,"html_url":"https://github.com/servian/bigquery-view-analyzer","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/servian/bigquery-view-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/servian%2Fbigquery-view-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/servian%2Fbigquery-view-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/servian%2Fbigquery-view-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/servian%2Fbigquery-view-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/servian","download_url":"https://codeload.github.com/servian/bigquery-view-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/servian%2Fbigquery-view-analyzer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261103451,"owners_count":23109932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bigquery","google-cloud","iam","python"],"created_at":"2024-09-24T23:03:36.174Z","updated_at":"2025-06-21T10:08:10.580Z","avatar_url":"https://github.com/servian.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BigQuery View Analyzer\n\n[![PyPI version](https://img.shields.io/pypi/v/bigquery-view-analyzer.svg)](https://pypi.python.org/pypi/bigquery-view-analyzer)\n[![Python versions](https://img.shields.io/pypi/pyversions/bigquery-view-analyzer.svg)](https://pypi.python.org/pypi/bigquery-view-analyzer)\n[![Build status](https://img.shields.io/travis/servian/bigquery-view-analyzer.svg)](https://travis-ci.org/servian/bigquery-view-analyzer)\n[![Github license](https://img.shields.io/github/license/servian/bigquery-view-analyzer.svg)](https://github.com/servian/bigquery-view-analyzer)\n\n## Description\n\n`bigquery-view-analyzer` is a command-line tool for visualizing dependencies and managing permissions between BigQuery views.\n\nTo 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.\n\n`bigquery-view-analyzer` automatically resolves these dependencies and applies the relevant permissions to all views and datasets referenced by the parent view.\n\n## Installation\n\n```bash\n$ pip install bigquery-view-analyzer\n```\n\n## Usage\n\n```bash\n$ bqva --help\n```\n\n[![asciicast](https://asciinema.org/a/252724.svg)](https://asciinema.org/a/252724)\n\n### Example: CLI\n\n![Example tree](/docs/example.png)\n\nGiven 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:\n\n- Authorized views for **`dataset_1`**\n  - `bqva-demo:dataset_3.view_a_b_c_d`\n- Authorized views for **`dataset_2`**\n  - `bqva-demo:dataset_3.view_a_b_c_d`\n  - `bqva-demo:dataset_1.view_c`\n- Authorized views for **`dataset_3`**\n  - `bqva-demo:dataset_2.view_d`\n  - `bqva-demo:dataset_4.shared_view`\n\nYou can easily visualize the above view hierarchy using the `bqva tree` command.\n\n```bash\n# View dependency tree and authorization status for 'bqva-demo:dataset_4.shared_view'\n$ bqva tree --status --no-key --view \"bqva-demo:dataset_4.shared_view\"\nbqva-demo:dataset_4.shared_view\n└── bqva-demo:dataset_3.view_a_b_c_d (⨯)\n    ├── bqva-demo:dataset_1.table_a (⨯)\n    ├── bqva-demo:dataset_1.table_b (⨯)\n    ├── bqva-demo:dataset_1.view_c (⨯)\n    │   └── bqva-demo:dataset_2.table_c (⨯)\n    └── bqva-demo:dataset_2.view_d (⨯)\n        └── bqva-demo:dataset_3.table_d (⨯)\n```\n\nPermissions can be applied automatically to all datasets referenced by the parent view using the `bqva authorize` command.\n\n```bash\n# Apply all permissions required by 'bqva-demo:dataset_4.shared_view'\n$ bqva authorize --view \"bqva-demo:dataset_4.shared_view\"\nbqva-demo:dataset_4.shared_view\n└── bqva-demo:dataset_3.view_a_b_c_d (✓)\n    ├── bqva-demo:dataset_1.table_a (✓)\n    ├── bqva-demo:dataset_1.table_b (✓)\n    ├── bqva-demo:dataset_1.view_c (✓)\n    │   └── bqva-demo:dataset_2.table_c (✓)\n    └── bqva-demo:dataset_2.view_d (✓)\n        └── bqva-demo:dataset_3.table_d (✓)\n```\n\nIf you want to revoke permissions for a view, you can do that too!\n\n```bash\n# Revoke all permissions granted to 'bqva-demo:dataset_4.shared_view'\n$ bqva revoke --view \"bqva-demo:dataset_4.shared_view\"\nbqva-demo:dataset_4.shared_view\n└── bqva-demo:dataset_3.view_a_b_c_d (⨯)\n    ├── bqva-demo:dataset_1.table_a (⨯)\n    ├── bqva-demo:dataset_1.table_b (⨯)\n    ├── bqva-demo:dataset_1.view_c (⨯)\n    │   └── bqva-demo:dataset_2.table_c (⨯)\n    └── bqva-demo:dataset_2.view_d (⨯)\n        └── bqva-demo:dataset_3.table_d (⨯)\n```\n\n### Example: Python library\n\nYou can import the library within a Python project to programatically apply permissions to multiple datasets.\n\n```python\n\nfrom bqva import ViewAnalyzer\nfrom google.cloud import bigquery\n\nclient = bigquery.Client()\n\n\ndef auth_views(datasets=[], **kwargs):\n    # get all datasets by default if none provided\n    if len(datasets) == 0:\n        datasets = client.list_datasets(max_results=1)\n    for dataset in datasets:\n        dataset = client.dataset(dataset)\n        tables = client.list_tables(dataset.dataset_id)\n        for table in tables:\n            if table.table_type == \"VIEW\":\n                view = ViewAnalyzer(\n                    project_id=table.project,\n                    dataset_id=table.dataset_id,\n                    view_id=table.table_id,\n                )\n                view.apply_permissions()\n            print(\n                f\"Authorised view: {table.project}.{table.dataset_id}.{table.table_id}\"\n            )\n\n\nauth_views([\"dataset_a\", \"dataset_b\"])\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservian%2Fbigquery-view-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fservian%2Fbigquery-view-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservian%2Fbigquery-view-analyzer/lists"}