Skip to main content

About flags variable

The flags variable contains values of flags provided on the command line.

Example usage:

{% if flags.FULL_REFRESH %}
drop table ...
{% else %}
-- no-op
{% endif %}

The list of available flags is defined in the flags module within dbt-core.

Recommended use cases include:

  • different materialization logic based on "run modes," such as flags.FULL_REFRESH and flags.STORE_FAILURES
  • running hooks conditionally based on the current command / task type, via flags.WHICH

Note: It is not recommended to use flags as an input to parse-time configurations, properties, or dependencies (ref + source). Flags are likely to change in every invocation of dbt, and their parsed values will become stale (and yield incorrect results) in subsequent invocations that have partial parsing enabled. For more details, see the docs on parsing.


For the full set of information passed from the CLI—subcommand, flags, arguments—you can use invocation_args_dict. This is equivalent to the args dictionary in run_results.json.

-- invocation_args_dict:
-- {{ invocation_args_dict }}

-- dbt_metadata_envs:
-- {{ dbt_metadata_envs }}

select 1 as id