denton
02/16/2024, 5:52 AMScout
02/16/2024, 5:52 AMyaml ops: run_dbt_b83ee_a92a1: config: full_refresh: true
In this example, run_dbt_b83ee_a92a1
is the name of the operation that backs the dbt software-defined assets. By setting the full_refresh
configuration to true
, you instruct Dagster to perform a full refresh when materializing the asset. Additionally, if you are using the @dbt_assets
decorator, you can define a function that includes the --full-refresh
argument when invoking the dbt
CLI. Here's an example from the documentation: python from dagster_dbt import dbt_assets @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()
In this code snippet, the my_dbt_assets
function checks if full_refresh
is set to True
in the configuration and, if so, adds the --full-refresh
argument to the dbt
CLI command. To use this in a job, you would define the job with the appropriate configuration to set full_refresh
to `True`: python 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)}), )
This job, when run, will execute the dbt
command with the --full-refresh
option, triggering a full refresh of the incremental dbt models.Pedram Navid
02/16/2024, 5:55 AMdenton
02/16/2024, 6:05 AM