SqlDBM can turn your BigQuery data models into Dataform-ready YAML, so you don't re-type structure, documentation, or data-quality checks by hand. Generate declarations for your existing source tables, or fully documented table and view actions — with descriptions, labels, partitioning, clustering, and assertions carried over from your model. Your engineers add only the SQL logic, and your model stays the single source of truth from design to pipeline.
Two outputs are available: YAML, one combined file to which you add SQL files in Dataform, and SQLX, one ready-to-compile .sqlx file per object with the SQL taken from your model.
Before you start
- Dataform generation is available for BigQuery projects only.
- Decide which output you need:
- Sources — declarations that register your existing BigQuery tables in Dataform. These carry names, descriptions, and columns, and work in Dataform as generated.
- Actions — table and view definitions that Dataform builds. These carry descriptions, columns, tags, labels, partitioning, clustering, data-quality assertions, and key constraints. You add the SQL for each action before running Dataform.
Generate the YAML
- Open your BigQuery project in SqlDBM.
- Go to Forward Engineering.
- Select the objects you want to include, the same way you select them for DDL generation.
- In Generation options, set Format to Dataform and Output to YAML.
- Set Type to Sources or Actions.
- Select Generate YAML. SqlDBM produces one combined YAML file containing all selected objects.
Object names, descriptions, and columns fill in automatically from your model, including nested STRUCT fields, which appear as multi-part column paths. Table or view type is inferred from each object, and physical properties like labels, partitioning, and clustering come from the BigQuery properties already defined on your objects.
Generate SQLX files
SQLX output creates one .sqlx file per selected object. SqlDBM writes the config block from your model and uses the SQL you store on each object as the file body.
- For each table or view that Dataform builds, open the object in edit mode, go to the Logic tab, and enter the query in the Dataform section. You can use Dataform templates such as
${ref("stg_customer")}. Save the project. - Go to Forward Engineering and select the objects you want to include.
- In Generation options, set Format to Dataform and Output to SQLX.
- Set Type to Sources (declarations only) or Actions.
- For Actions, choose how tables are generated in Table actions:
- Table — Dataform logic (default): a
tableaction whose body is the table's Dataform logic. - Operations — CREATE TABLE IF NOT EXISTS: an
operationsaction that creates the table from the model's DDL. Use this when the table is loaded outside Dataform.
- Table — Dataform logic (default): a
- Select Generate SQLX.
The result shows a file tree with one file per object at definitions/<dataset>/<object_name>.sqlx. Select a file to view it. For example:
config {
type: "table",
name: "dim_customer",
schema: "operations",
description: "Customer dimension",
columns: {
customer_id: "Surrogate key",
customer_name: "Full legal name"
},
bigquery: {
partitionBy: "DATE(created_at)",
clusterBy: ["customer_id"]
},
assertions: {
uniqueKey: ["customer_id"],
nonNull: ["customer_id", "customer_name"]
}
}
SELECT
customer_id,
customer_name
FROM ${ref("stg_customer")}
post_operations {
ALTER TABLE ${self()} ADD PRIMARY KEY (customer_id) NOT ENFORCED
}
Select Download to get a ZIP of the definitions/ folder, or Push to Git to commit the files to the repository and base path already configured for Dataform YAML.
Keep in mind:
- The Dataform logic is used as written. SqlDBM does not add
ref()calls or reformat your SQL, and the Dataform section is never included in DDL, dbt, or YAML output. - A table with no Dataform logic gets a placeholder query that fails on purpose when run, so an unfinished file can't overwrite existing data. Replace it by adding the query in SqlDBM and generating again.
- A view or materialized view with no Dataform logic is skipped and marked in the file tree with Dataform logic is empty.
- Every file sets
schema(the BigQuery dataset). The project comes from your Dataformworkflow_settings.yaml. - Each generation replaces existing files at the same paths, so keep the SQL in SqlDBM rather than editing it in the repository. Incremental tables are not generated.
Use the file in Dataform
For YAML output:
- In your Dataform workspace, add the generated file to the
definitions/folder. - Sources: no further edits needed — declarations compile and run as generated.
-
Actions: for each table or view, add a
filename:line pointing to a SQL file, then create that file with the transformation SQL. Use an explicit.sqlextension — the Dataform editor defaults to.sqlx, which registers a duplicate action. - Compile and run. Primary and foreign keys apply through post-operations using fully qualified table names, and foreign-key dependencies are declared so parent tables build first.
For SQLX output, place the definitions/ folder at the root of your Dataform repository (or use Push to Git), then compile and run. No further edits are needed once every object has Dataform logic.