#16543·dbt-core

[Feature] Let custom materializations declare they are "safe" (config on the materialization macro)

Author: b-perCreated Oct 1, 2026Updated Oct 1, 2026
Labelstype:featuretriagev2

Which version of dbt is this feature for?

dbt 2.x

Describe the feature

Let the author of a custom materialization declare on the macro itself that it follows a defined contract, for example safe: true.

dbt can detect that a materialization is custom, but it can't tell a well-behaved one from one that does something unexpected. A declaration would let dbt trust the ones that opt in:

  • Static analysis: a custom materialization can change the columns of the relation it builds, so the analyzed schema no longer matches. Today the user has to set static_analysis: off on each such model. With the flag, dbt knows which materializations it can trust. In the future, static analysis could be limited when safe is false, or allowed only when it is true.
  • dbt State (reusing a model instead of rebuilding it when nothing changed): dbt finds a model's upstream tables by parsing its compiled SQL. For a custom materialization that SQL isn't necessarily a plain query, so dbt falls back to the manifest dependency graph and treats the model as a special case. A safe materialization could be handled like a built-in one.
  • Write-audit-publish (#16509): that issue asks whether custom materializations can take part, since they can change the fully qualified name. Only the ones that declare themselves safe could.

Proposed shape

Config on the macro, in the properties YAML:

yaml
macros:
  - name: materialization_my_table_snowflake
    config:
      safe: true

safe needs a narrow, documented meaning, for example: "the relation's columns equal the compiled SELECT's columns, and only the node's own relation is written."

Alternatives considered

Alternative Drawback
Keyword in the tag: {% materialization foo, adapter='x', safe=true %} Needs a parser change and may not parse in dbt-core v1 (unverified).
Convention in config.meta Unvalidated free-form namespace, so it can't be a contract.
Per-model config Repeated on every model, written by the user rather than the author, and doesn't help dbt State or write-audit-publish.
Keep inferring from name or dispatch (today) Can only say custom or not, never well-behaved or not.
Infer safety from the macro body Arbitrary Jinja, so it would be fragile.
Several declared capabilities instead of one flag Probably the right long-term shape, but a larger design. A single flag can be split later.

Open questions

  • What does an unset flag mean for existing materializations?
  • Can a project override the flag on a package's materialization?

Anything else?

Related: #16509