Skip to main content

datus-bigquery

BigQuery database adapter for Datus.

Timeouts

timeout_seconds must be positive and now bounds driver I/O as well as pool checkout where applicable. Long operations may need a larger value. Server execution deadlines and supported overrides are described in the shared timeout policy and real-database validation. A socket/RPC timeout is distinct from an overall operation deadline.

Installation

pip install datus-bigquery

This will automatically install the required dependencies:

  • datus-db-core
  • datus-sqlalchemy
  • sqlalchemy-bigquery

Configuration

The adapter is automatically registered with Datus when installed. Configure your database connection in your Datus configuration:

namespace:
  analytics:
    type: bigquery
    project: your-gcp-project-id
    dataset: your_dataset
    credentials_path: /path/to/service-account.json
    # Or credentials_info / credentials_base64 for secret-managed deployments.
    # Configure only one credentials mechanism.
    billing_project_id: optional-quota-project
    location: US

Application Default Credentials are used when none of credentials_path, credentials_info, or credentials_base64 is configured. BigQuery's project and dataset map to Datus's catalog and database levels; there is no schema level below the dataset.

Usage

Or use programmatically:

from datus_bigquery import BigQueryConnector, BigQueryConfig

# Using config object
config = BigQueryConfig(
    project="your-gcp-project-id",
    dataset="your_dataset",
    credentials_path="/path/to/service-account.json",
    location="US"
)
connector = BigQueryConnector(config)

# Or using dict
connector = BigQueryConnector({
    "project": "your-gcp-project-id",
    "dataset": "your_dataset",
})

# Test connection
connector.test_connection()

# Execute query
result = connector.execute(
    {"sql_query": "SELECT * FROM `your-gcp-project-id.your_dataset.your_table` LIMIT 10"}
)
print(result.sql_return)

# Get table list
tables = connector.get_tables(database_name="your_dataset")
print(f"Tables: {tables}")

# Get table schema
schema = connector.get_schema(database_name="your_dataset", table_name="your_table")
for column in schema:
    print(f"{column['name']}: {column['type']}")

Features

  • Full query operations (SELECT, INSERT, DDL)
  • Separate metadata retrieval for tables, views, and materialized views
  • Sample data extraction
  • Multiple result formats (pandas, arrow, csv, list)
  • Project and dataset level navigation
  • BigQuery-specific migration hints and DDL validation
  • Packaged SQL generation skill for GoogleSQL
  • Comprehensive error handling

Testing

Quick Start

# Unit tests (no BigQuery connection required)
cd datus-bigquery
uv run pytest tests/unit/ -v

# All tests with coverage
uv run pytest tests/ -v --cov=datus_bigquery --cov-report=term-missing

Integration Tests (Requires BigQuery)

# Set environment variables
export BIGQUERY_PROJECT=your-gcp-project-id
export BIGQUERY_DATASET=datus_test
export BIGQUERY_CREDENTIALS_PATH=/path/to/service-account.json
# CI uses BIGQUERY_CREDENTIALS_INFO containing the service-account JSON object.
export BIGQUERY_LOCATION=US

# Run integration tests
cd datus-bigquery
uv run pytest tests/integration/ -m integration -v

# Run all acceptance tests (unit + integration)
uv run pytest tests/ -m acceptance -v

Test Markers

Marker Description
integration Requires a BigQuery connection
acceptance Core functionality tests (subset of unit + integration)

Code Structure

datus-bigquery/
├── datus_bigquery/
│   ├── __init__.py          # Package exports
│   ├── config.py            # BigQueryConfig model
│   ├── connector.py         # BigQueryConnector implementation
│   ├── handlers.py          # Generic Datus URI/context hooks
│   ├── skills.py            # Skill discovery and compatibility hook
│   └── skills/db-bigquery-sql/SKILL.md
├── tests/
│   ├── unit/
│   │   ├── test_config.py          # Config validation tests
│   │   └── test_connector_unit.py  # Connector unit tests
│   └── integration/
│       ├── conftest.py             # Fixtures (config, connector)
│       └── test_integration.py     # Integration tests
├── pyproject.toml
└── README.md

Development

Setup

# From the workspace root
uv sync --package datus-bigquery

Code Quality

# Format code
uv run ruff format --check datus-bigquery
uv run ruff check datus-bigquery

Requirements

  • Python >= 3.12
  • datus-db-core >= 0.1.6
  • datus-sqlalchemy >= 0.1.8
  • sqlalchemy-bigquery >= 1.17.2

License

Apache License 2.0

Metadata

Release files for datus-bigquery 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for datus-bigquery 0.1.1
File Size Uploaded Provenance
datus_bigquery-0.1.1.tar.gz 23.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for datus-bigquery 0.1.1
File Interpreter ABI Platform
datus_bigquery-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 40.9 kB

Release files / datus_bigquery-0.1.1.tar.gz

Download URL datus_bigquery-0.1.1.tar.gz
Size 23.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c20c736b1c8db594aa256a0336b85d89e13ca033af9dabf3c9288d6c7256fb7d
BLAKE2b-256 checksum
How to use checksums
f8c3899fdaf85a1758567cd2c8f49a4b2c09db7ff4cf7755ee81d6cad8b73889
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / datus_bigquery-0.1.1-py3-none-any.whl

Download URL datus_bigquery-0.1.1-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2279baaf75c2e22ca956cab18c4bdc8f5da17d1286cdd57d5f9599e619b86ac
BLAKE2b-256 checksum
How to use checksums
2174a9df8c777f1f695e139a8a04eab46408a006475c863ff3df6823f67843c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for datus-bigquery 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page