Andy Smith
03/05/2024, 4:19 PMScout
03/05/2024, 4:19 PM--full-refresh
flag with @dbt_assets
by adding a custom configuration class: python from pathlib import Path from dagster import AssetExecutionContext, Config from dagster_dbt import dbt_assets, DbtCliResource class MyDbtConfig(Config): full_refresh: bool @dbt_assets(manifest=Path("target", "manifest.json")) def my_dbt_assets(context: AssetExecutionContext, dbt: DbtCliResource, config: MyDbtConfig): dbt_build_args = ["build"] if config.full_refresh: dbt_build_args += ["--full-refresh"] yield from dbt.cli(dbt_build_args, context=context).stream()
When you define a job that includes these dbt assets, you can specify the full_refresh
configuration to be True
in the RunConfig
. This will ensure that the dbt models are fully refreshed during the run: python from dagster import define_asset_job, AssetSelection, RunConfig dbt_incremental_full_refresh_job = define_asset_job( "dbt_incremental_full_refresh_job", selection=AssetSelection(my_dbt_assets), config=RunConfig({"my_dbt_assets": MyDbtConfig(full_refresh=True)}), )
When you execute this job, Dagster will pass the --full-refresh
flag to the dbt CLI command, triggering a full refresh of the dbt models.