<@U0667DNC02Y> how do i trigger a full refresh com...
# ask-ai
d
@Scout how do i trigger a full refresh command to materialize a dbt asset?
s
To trigger a full refresh command to materialize a dbt asset, you can pass configuration to the underlying operation that backs your software-defined assets. This configuration can be passed in the launchpad to ensure that a full refresh occurs. The documentation provides an example of how to do this:
Copy code
yaml 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:
Copy code
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`:
Copy code
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.
p
d
Much appreciated!
dagster yay 1