No project description provided
Project description
bq-validator
This is a yet another python-based BigQuery query validator with advanced features for CI/CD pipelines and development workflows.
The bq query --dry_run command enables us to validate queries.
However, the bq command doesn't support service account impersonation, even though it supports workload identity federation credentials at Google Cloud SDK 390.0.0.
The bq-validator command would be useful, when we take advantage of service account impersonation to validate BigQuery queries.
Features
- Parallel validation of multiple SQL files
- Service account impersonation support
- Statistics output in JSON format for CI/CD integration
- Flexible error handling with warning options for empty files
- Structured JSON output for programmatic processing
Install
The package is available on pypi
pip install -U bq-validator
How to use
$ bq-validator --help
Usage: bq-validator [OPTIONS] PATH
Validate BigQuery queries
PATH is either of a SQL file path or a directory. When it is a directory,
the command recursively validates all SQL files in the directory.
Options:
--quota_project TEXT BigQuery client project ID
--client_project TEXT BigQuery client project ID
--client_location TEXT BigQuery client location
--impersonate_service_account TEXT
Impersonate service account email
--num_parallels INTEGER Number of parallel query validations
--verbose Enable verbose output
--warn-on-empty Show just warning(s) not to raise error(s)
if the given file(s) are empty
--stats Show the summary of the results
--help Show this message and exit.
Examples
Basic Usage
Validate a single SQL file:
bq-validator path/to/query.sql
Validate all SQL files in a directory:
bq-validator path/to/sql/directory/
Advanced Options
Show validation statistics in JSON format:
bq-validator --stats path/to/sql/directory/
Treat empty SQL files as warnings instead of errors:
bq-validator --warn-on-empty path/to/sql/directory/
Combine options for detailed validation:
bq-validator --stats --warn-on-empty --verbose path/to/sql/directory/
Output Examples
With --stats option, you'll see a JSON summary:
{
"summary": {
"total": 5,
"success": 3,
"errors": 1,
"warnings": 1
}
}
Errors and warnings are shown as JSON objects:
{
"path/to/invalid.sql": {
"query": "SELECT invalid_column FROM invalid_table",
"error": "Table \"invalid_table\" must be qualified with a dataset..."
},
"path/to/empty.sql": {
"query": "",
"warning": "Query is empty"
}
}
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bq_validator-0.9.2.tar.gz.
File metadata
- Download URL: bq_validator-0.9.2.tar.gz
- Upload date:
- Size: 95.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9565e974cff02f648b969c32b4daafa1a73294a9d59b52c773ef58eca094e267
|
|
| MD5 |
595d37eca9fdac61991693a4951a2dcc
|
|
| BLAKE2b-256 |
4f74383de8a590053f7c25d172556bded72e50adb35f605798dd36f308c78186
|
File details
Details for the file bq_validator-0.9.2-py3-none-any.whl.
File metadata
- Download URL: bq_validator-0.9.2-py3-none-any.whl
- Upload date:
- Size: 17.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1fe0c562894c9e0ffca430746f8813b0a5dd3c80a6d30cb15d60263c905ca05
|
|
| MD5 |
c6133be754a1acda5c0921e97ecd7873
|
|
| BLAKE2b-256 |
7c10f32a26b450c9d30b2593d15ddb4cdf53e3a192c471b97f94dbea992770e1
|