Setting the file. One moment.
Subchapter 2.117
references/integrations/dagster-dbt/asset-checks.mdMarkdown1 KBView on GitHub
dbt tests are loaded as Dagster asset checks by default (enabled in dagster-dbt 0.23.0+).
By default, only tests on dbt models are loaded as checks. To include tests on sources:
Component approach:
attributes:
translator_settings:
enable_source_tests_as_checks: truePythonic approach:
from dagster_dbt import DagsterDbtTranslator, DagsterDbtTranslatorSettings
translator = DagsterDbtTranslator(
settings=DagsterDbtTranslatorSettings(enable_source_tests_as_checks=True)
)
@dbt_assets(manifest=my_dbt_project.manifest_path, dagster_dbt_translator=translator)
def my_dbt_assets(context, dbt: DbtCliResource):
yield from dbt.cli(["build"], context=context).stream()For singular tests that depend on multiple models, specify the target model in the test’s config block:
{{
config(
meta={
'dagster': {
'ref': {
'name': 'customers',
'package': 'my_dbt_assets',
'version': 1,
},
}
}
)
}}
SELECT ...The ref structure mirrors dbt’s
ref function (opens in a new tab) parameters. Without this
metadata, the test still runs but emits an AssetObservation instead of an asset check result.