SqlBuildProject
Project metadata and DAG artifact preparation.| Parameter | Default | Description |
|---|---|---|
project_dir | (required) | Path to the SQLBuild project root |
target_path | "target" | Relative path to the target directory |
dag_filename | "sqlbuild_dag.json" | DAG artifact filename |
sqb_command | ("sqb",) | Command to invoke SQLBuild CLI |
prepare_project_cli_args | ("compile", "--dag") | CLI args used by prepare() to generate the DAG |
Methods
| Method | Description |
|---|---|
dag_path | Property. Returns the full path to the DAG artifact (project_dir / target_path / dag_filename). |
prepare() | Runs sqb compile --dag <dag_path> to generate the DAG artifact. Raises DagsterProjectPrepareError on failure. |
prepare_if_dev() | Calls prepare() only when the DAGSTER_IS_DEV_CLI environment variable is set. |
SqlBuildCliResource
DagsterConfigurableResource that shells out to the SQLBuild CLI.
| Parameter | Default | Description |
|---|---|---|
project_dir | "." | Path to the SQLBuild project root, or a SqlBuildProject instance |
sqb_command | ["sqb"] | Command to invoke SQLBuild CLI |
dag_path | None | Path to the DAG artifact. When set, enables asset selection bridging and structured event emission. |
cli()
Create a CLI invocation for the provided command arguments.SqlBuildCliInvocation.
SqlBuildCliInvocation
A running or completed SQLBuild CLI subprocess.Methods
| Method | Description |
|---|---|
wait() | Wait for the process to complete. Streams stdout/stderr in real time. Returns self. |
stream() | Wait for the process, then yield Dagster MaterializeResult and AssetCheckResult events parsed from execution JSON. |
is_successful() | Returns True if exit code is 0. |
get_error() | Returns a Dagster Failure if the process failed, None otherwise. |
get_artifact(name) | Read a JSON artifact from the project’s target/ directory. |
Properties
| Property | Description |
|---|---|
stdout | Captured stdout after wait() or stream(). |
stderr | Captured stderr after wait() or stream(). |
returncode | Process exit code after completion. |
execution_payload | Parsed execution JSON, if available. |
stream() behavior
stream() is the primary way to emit Dagster events from a SQLBuild execution:
- Waits for the subprocess to complete while streaming output to stdout/stderr
- Reads the structured execution JSON (from
--json-outputtempfile) - Maps each completed asset to a
MaterializeResultwith metadata (status, duration, row counts) - Maps each check result to an
AssetCheckResultwith pass/fail, severity, and check metadata - If the DAG artifact is available, results are matched to the correct Dagster asset keys
- Raises
Failureif the process exited non-zero andraise_on_erroris set
sqlbuild_assets
Decorator that creates a Dagster multi-asset definition from a SQLBuild DAG artifact.| Parameter | Default | Description |
|---|---|---|
project | None | SqlBuildProject instance. Mutually exclusive with dag. |
dag | None | DAG artifact as a path, string, or pre-loaded dict. Mutually exclusive with project. |
translator | SqlBuildDagsterTranslator() | Translator for asset keys, groups, tags, and metadata. |
name | None | Override the Dagster multi-asset name. |
include_scenario_checks | True | Whether to include scenario checks alongside test and audit checks. |
required_resource_keys | None | Additional Dagster resource keys to require. |
project nor dag is provided, the decorator looks for target/sqlbuild_dag.json in the current directory.
sqlbuild_scenario_checks
Decorator that creates a Dagster multi-asset-check definition for SQLBuild scenarios only. Useful when you want to run scenarios separately from the main build.sqlbuild_assets except there is no include_scenario_checks flag.
SqlBuildDagsterTranslator
Customise how SQLBuild DAG nodes map to Dagster asset metadata. Subclass and override any method.Methods
| Method | Arguments | Returns | Default behavior |
|---|---|---|---|
get_asset_key | node | AssetKey | AssetKey(node["asset_key"]) |
get_group_name | node | str | None | Node kind (e.g. "model", "source") |
get_tags | node | dict[str, str] | sqlbuild/kind tag plus any model tags |
get_metadata | node | dict[str, Any] | sqlbuild_id, sqlbuild_name, sqlbuild_kind, path, target, description, columns |
get_description | node | str | None | Node description if present |
get_check_name | check | str | "{kind}__{name}" with optional column/target suffix |
get_check_metadata | check | dict[str, Any] | Check ID, kind, name, and selector |
Node structure
Eachnode dict passed to translator methods contains:
| Kind | Asset key example |
|---|---|
| Task | ("task", "prepare_orders") |
| Asset | ("asset", "orders_export") |
| Loader | ("loader", "raw_orders") |
Check structure
Eachcheck dict passed to check translator methods contains:

