Skip to main content

datus-bigquery

BigQuery database adapter for Datus.

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datus_bigquery-0.1.0.tar.gz (20.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datus_bigquery-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file datus_bigquery-0.1.0.tar.gz.

File metadata

  • Download URL: datus_bigquery-0.1.0.tar.gz
  • Upload date:
  • Size: 20.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for datus_bigquery-0.1.0.tar.gz
Algorithm Hash digest
SHA256 35643936cd5ca170159e383ce68505652cd315997f44cbed991a7ccf953c271c
MD5 6a3240f76df84b64c2d023a1238f104d
BLAKE2b-256 24be760c0929593d26855900ed02038c66aa8e372685603e1912d9d1dda3be29

See more details on using hashes here.

File details

Details for the file datus_bigquery-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: datus_bigquery-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for datus_bigquery-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 519ede94164e04116dffdf8e48ac022d3721a5ac76d9fe54840b9807d9141d81
MD5 d46d2cd941f1d6b82672d8f5833cc28f
BLAKE2b-256 d4a70ca28b6bef33ab65b457d9eb91289e2d03e62dd12283c50d4f1ee439d290

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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