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"
}
}
Metadata
Release files for bq-validator 0.9.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bq_validator-0.9.2.tar.gz | 95.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bq_validator-0.9.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 112.7 kB
Release files / bq_validator-0.9.2.tar.gz
| Download URL | bq_validator-0.9.2.tar.gz |
|---|---|
| Size | 95.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9565e974cff02f648b969c32b4daafa1a73294a9d59b52c773ef58eca094e267
|
|
BLAKE2b-256 checksum How to use checksums |
4f74383de8a590053f7c25d172556bded72e50adb35f605798dd36f308c78186
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / bq_validator-0.9.2-py3-none-any.whl
| Download URL | bq_validator-0.9.2-py3-none-any.whl |
|---|---|
| Size | 17.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1fe0c562894c9e0ffca430746f8813b0a5dd3c80a6d30cb15d60263c905ca05
|
|
BLAKE2b-256 checksum How to use checksums |
7c10f32a26b450c9d30b2593d15ddb4cdf53e3a192c471b97f94dbea992770e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Security for bq-validator 0.9.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.