SCD2 BigQuery Engine
Version: 0.1.0
License: MIT
Status: ✅ Production Ready
Overview
BigQuery-first SCD Type 2 dimension builder with SQLX template generation for Dataform/dbt.
Generates production-ready SQLX files that implement full SCD Type 2 logic including:
- Hash-based change detection
- Effective date tracking
- Soft deletes
- Late arrival handling
- BigQuery optimizations (partitioning, clustering)
Why This Module?
- dbt snapshots are dbt-locked and Snowflake-optimized
- Existing SCD2 tutorials use stored procedures (hard to version control)
- No declarative, config-driven SCD2 solution for BigQuery
Features (v0.1.0 MVP)
- ✅ SQLX template generator for standard SCD2 pattern
- ✅ Hash-based change detection (MD5/SHA256)
- ✅ Effective dating with late arrival handling
- ✅ Soft delete support
- ✅ YAML config → SQLX output
- ✅ CLI + Python API
Quick Start
Installation
pip install scd2-bq-engine
Initialize Configuration
# Create a new dimension configuration
scd2-bq init dim_employee \
--source-table project.dataset.stg_employees \
--business-keys employee_number \
--tracked-columns first_name,last_name,job_code,department
Generate SQLX
# Generate SCD2 dimension SQLX file
scd2-bq generate \
--config dim_employee_config.yaml \
--output-file dim_employee.sqlx
Python API
from scd2_bq_engine import SCD2Generator, SCD2Config
# Create configuration
config = SCD2Config(
dimension_name="dim_employee",
source_table="project.dataset.stg_employees",
business_keys=["employee_number"],
tracked_columns=["first_name", "last_name", "job_code"]
)
# Generate SQLX
generator = SCD2Generator(config)
generator.write_sqlx("dim_employee.sqlx")
Directory Structure
scd2-bq-engine/
├── src/scd2_bq_engine/
│ ├── generator.py # Core SQLX generator
│ ├── templates/ # Jinja2 SQLX templates
│ └── validators.py # Config validation
├── tests/
├── examples/
└── docs/
License
MIT - see LICENSE
Metadata
Release files for scd2-bq-engine 0.1.0
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 | Actions |
|---|---|---|---|---|
| scd2_bq_engine-0.1.0.tar.gz | 10.7 kB | Without provenance | Details for scd2_bq_engine-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scd2_bq_engine-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for scd2_bq_engine-0.1.0-py3-none-any.whl |
Total release size: 20.6 kB
Release files / scd2_bq_engine-0.1.0.tar.gz
| Download URL | scd2_bq_engine-0.1.0.tar.gz |
|---|---|
| Size | 10.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a42681ba0cda0e36ed0f46abbadd431674fd6b1362eea77cb14831cb4db40c71
|
|
BLAKE2b-256 checksum How to use checksums |
8a073b7a53a0c618d5bfbf1dcd3d99fe4230d7e8ac0c00b829b63e4c3d789efe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / scd2_bq_engine-0.1.0-py3-none-any.whl
| Download URL | scd2_bq_engine-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2861f96d7641cb85b9d828db5912545a5fa2614718d7d7272610b2ed2085941e
|
|
BLAKE2b-256 checksum How to use checksums |
1a7b75083272e77841120af363a5febe14da845c0afdb8aa7c361084991707ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for scd2-bq-engine 0.1.0
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.