Skip to main content

🚚 dataform-view-migrator

Export BigQuery VIEW definitions into Dataform with ease. 🚀

dataform-view-migrator is a handy CLI tool that discovers your BigQuery views and turns them into Dataform-ready .sqlx or .sql files. It handles complex folder structures, provides safe backup policies, and automatically generates Dataform configuration headers.


⚡ Super Quickstart

  1. Install

    pip install dataform-view-migrator
    
  2. Authenticate

    gcloud auth application-default login
    
  3. Migrate!

    dataform-view-migrator migrate-views --source-project my-project --dest ./my-dataform-repo
    

💡 Example Input & Output

BigQuery View (my_project.my_dataset.daily_sales):

SELECT date, SUM(amount) as total_sales
FROM `my_project.my_dataset.raw_transactions`
GROUP BY 1

Generated Dataform File (my-dataform-repo/my_dataset/daily_sales.sqlx):

config {
  type: "view",
  schema: "my_dataset",
  name: "daily_sales",
  description: "CREATED BY DATAFORM.",
  tags: ["my-tag","another-tag"],
}

SELECT date, SUM(amount) as total_sales
FROM `my_project.my_dataset.raw_transactions`
GROUP BY 1

✨ Features

  • 🔍 Auto-discovery: Find all views across multiple datasets automatically.
  • 📂 Flexible Layout: Map BigQuery datasets to custom subfolders in your Dataform project.
  • 🛡️ Safe Writes: Choose to skip, backup, or force overwrite existing files.
  • 📝 Dataform Headers: Automatically adds config { type: "view", ... } to your .sqlx files.
  • 🧪 Dry Run: Preview exactly what will happen before making any changes.
  • 🚀 Fast: Uses INFORMATION_SCHEMA for high-performance discovery in large projects.

🛠 Prerequisites

  • Python 3.10+
  • GCP Authentication via Application Default Credentials (ADC).

📖 Commands

  • ping-bq: 📡 Verify your authentication and BigQuery access.
    dataform-view-migrator ping-bq --project my-project
    
  • migrate-views: 🚜 The main event. Discovers and exports views.
    dataform-view-migrator migrate-views [options]
    

Run --help on any command for a full list of available options.


⚙️ Configuration

While you can use CLI flags, using a TOML file is often easier for recurring tasks. Copy dataform_view_migrator.example.toml to dataform_view_migrator.toml and customize it.

Available Keys

Key Type Default Description
source_project string Required. The GCP project ID containing your views.
dest string Required. Local path to your Dataform repository.
datasets_include list [] List of datasets to process. If empty, processes all.
datasets_exclude list [] List of datasets to ignore.
location string BigQuery region (e.g., US, EU). Required for high-performance discovery.
ext string sqlx File extension: sqlx or sql.
overwrite string skip Policy: skip, backup (renames existing), or force.
add_dataform_header boolean true Prepend config {} block to files.
dry_run boolean false If true, only show what would happen.
dataform_header.description string Optional description for the Dataform config block.
dataform_header.tags list [] Optional list of tags for the Dataform config block.
dataset_folders dict Map dataset IDs to custom subfolders (e.g., ds_id = "path/to/dir").

📂 Output Layout

By default, files are saved as dest/<dataset>/<view_name>.sqlx. You can remap dataset names to specific folders using the dataset_folders setting in your config:

[dataset_folders]
raw_data = "sources/raw"
analytics = "definitions/reporting"

🤝 Contributing & Development

We love contributions! Please check out DEVELOPMENT.md for setup instructions, linting rules, and testing guidelines.



Developed by Alan Vainsencher.

Metadata

Release files for dataform-view-migrator 0.1.6

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

Source distribution (sdist)

Source distribution for dataform-view-migrator 0.1.6
File Size Uploaded Provenance
dataform_view_migrator-0.1.6.tar.gz 51.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dataform-view-migrator 0.1.6
File Interpreter ABI Platform
dataform_view_migrator-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 64.6 kB

Release files / dataform_view_migrator-0.1.6.tar.gz

Download URL dataform_view_migrator-0.1.6.tar.gz
Size 51.5 kB
Tags Source
SHA-256 checksum
How to use checksums
56fe3af50a6b2fd0282eebfa818b442a845494c91647e54b868efba2c081b4ce
BLAKE2b-256 checksum
How to use checksums
62aa3edef74c61b38ecf15887701ce6153b1ce242211fe5f512ee777130ac8b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.25

Release files / dataform_view_migrator-0.1.6-py3-none-any.whl

Download URL dataform_view_migrator-0.1.6-py3-none-any.whl
Size 13.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55a9121ad1a1615f1efb6372437c48b9add0bf759f93b338531477d2e5c7c937
BLAKE2b-256 checksum
How to use checksums
372a919683fe2f767a0768edec157ebbe8989e4b4af6839b6f84621725f822dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.25

Security for dataform-view-migrator 0.1.6

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.

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