Dataform Support
Querylab.io supports Google Cloud Dataform SQLX templates. Write and test Dataform models in the editor with completions, diagnostics, and mapping management. No Dataform CLI required.
Getting Started
Dataform mode activates when Querylab.io detects SQLX patterns:
${ ... }template expressionsconfig { ... }blocksjs { ... }blockspre_operations { ... }orpost_operations { ... }blocks
Paste any Dataform SQLX into the editor and the Dataform panel appears.
Enable/Disable
Dataform mode is enabled by default. To toggle it:
Settings > SQL Frameworks > Enable Dataform Mode
See Settings for all Dataform-related settings.
The Dataform Panel
When Dataform mode activates, a Dataform button appears in the status bar at the bottom of the editor. Click it to open the Dataform panel on the right side.
- Left-click the status bar button to toggle the panel
- Right-click the button to deactivate Dataform mode for this tab
The panel has six sections:
Active Directives
Lists all Dataform directives found in your SQL:
ref('table_name')referencesresolve('project.dataset.table')referencesdataform.projectConfig.vars.namevariable references
Each shows the directive and its resolution status. Click unresolved items to add a mapping.
Detected Tables
Tables from your FROM and JOIN clauses that are not yet converted to Dataform refs. Click Convert to Dataform ref to replace the table reference with ${ ref("table_name") }.
Detected Values
String literals that could be extracted as Dataform variables. Click Convert to Dataform variable to replace the value with ${ dataform.projectConfig.vars.name }.
Table Mappings
Manage your ref() and resolve() mappings. Each mapping connects a Dataform reference to its BigQuery table.
- ref mappings resolve
${ ref("name") }to a BigQuery table - resolve mappings resolve
${ resolve("name") }to a fully-qualified table
Add, search, and remove mappings the same way as dbt mappings. Mappings are saved globally.
Variable Mappings
Manage your project variable mappings. Each maps a variable name to its resolved value for ${ dataform.projectConfig.vars.name } expressions.
Options
| Option | Description |
|---|---|
| Incremental mode | When enabled, when(incremental()) blocks are kept during preprocessing. When disabled, they are stripped. |
| Auto-apply saved mappings | Resolve ref() and vars using your saved mappings. |
SQLX Syntax Reference
Dataform uses SQLX template syntax, which differs from dbt's Jinja:
config {
type: "view",
schema: "analytics"
}
SELECT
id,
name,
created_at
FROM ${ ref("source_table") }
WHERE created_at >= ${ dataform.projectConfig.vars.start_date }
Common Patterns
| Pattern | Purpose |
|---|---|
${ ref("table") } | Reference a Dataform model |
${ resolve("project.dataset.table") } | Reference any BigQuery table |
${ self() } | Reference current model's output table |
${ dataform.projectConfig.vars.name } | Access a project variable |
${ when(incremental(), "WHERE id > last_id") } | Conditional SQL for incremental queries |
Config Blocks
SQLX files can include configuration blocks at the top:
config {
type: "incremental",
schema: "analytics",
bigquery: {
partitionBy: "DATE(created_at)",
clusterBy: ["user_id"]
}
}
Inlay Hints
When enabled, resolved values appear inline after SQLX expressions as faded annotations:
SELECT *
FROM ${ ref("users") } -- → my_project.analytics.users
WHERE date >= ${ dataform.projectConfig.vars.start_date } -- → 2024-01-01
Toggle in Settings > SQL Frameworks > Dataform > Inlay Hints.
Diagnostics
Querylab.io flags Dataform issues with editor squiggles:
- Unresolved ref:
${ ref("unknown") }— warning with quick fix to add mapping - Unresolved resolve:
${ resolve("unknown") }— warning - Unresolved variable:
${ dataform.projectConfig.vars.unknown }— warning
Click the lightbulb or press Cmd/Ctrl+. to access quick fixes.
Import Config
Bulk-import mappings from your Dataform project's dataform.json:
- Click the Import button (upload icon) in the panel header
- Paste the contents of your
dataform.jsonfile - Review the preview showing counts of tables and variables
- Choose Merge (add to existing) or Replace (overwrite all)
Context Menu
Right-click in the editor when Dataform mode is active for additional actions:
- Convert to Dataform ref — Replace selected table name with
${ ref("...") } - Convert to Dataform variable — Replace selected value with a project variable
dbt vs Dataform
| Feature | dbt | Dataform |
|---|---|---|
| Template syntax | Jinja: {{ }}, {% %} | SQLX: ${ } |
| Ref syntax | {{ ref('model') }} | ${ ref("model") } |
| Source syntax | {{ source('schema', 'table') }} | ${ resolve("project.dataset.table") } |
| Variables | {{ var('name') }} | ${ dataform.projectConfig.vars.name } |
| Incremental | {% if is_incremental() %} | ${ when(incremental(), "sql") } |
| Import from | manifest.json | dataform.json |
| Export | Generate model YAML | Not supported |
Both modes can be enabled simultaneously; Querylab.io detects which syntax is in use per tab.
Related Features
- dbt Support — dbt Jinja template support
- Settings — dbt and Dataform settings
- Code Quality — Diagnostic rules