dbt-labs/dbt-core · warning

Constraints not supported for file format: {adapter.resolve_

Error message

Constraints not supported for file format: {adapter.resolve_file_format(config)}

What it means

Databricks only supports model constraints (contracts or persisted constraints) on Delta tables. When the model has an enforced contract or `persist_constraints=true` but `adapter.resolve_file_format(config)` resolves to something other than `delta` (e.g. parquet, csv, json), dbt warns that the constraints will not be applied and skips them.

Source

Thrown at crates/dbt-loader/src/dbt_macro_assets/dbt-databricks/macros/relations/constraints.sql:14

{# Persist table-level and column-level constraints. #}
{% macro persist_constraints(relation, model) %}
  {{ return(adapter.dispatch('persist_constraints', 'dbt')(relation, model)) }}
{% endmacro %}

{% macro databricks__persist_constraints(relation, model) %}
  {%- set contract_config = config.get('contract') -%}
  {% set has_model_contract = contract_config and contract_config.enforced %}
  {% set has_databricks_constraints = config.get('persist_constraints', False) %}

  {% if (has_model_contract or has_databricks_constraints) %}
    {% if adapter.resolve_file_format(config) != 'delta' %}
      {# Constraints are only supported for delta tables #}
      {{ exceptions.warn("Constraints not supported for file format: " ~ adapter.resolve_file_format(config)) }}
    {% elif relation.is_view %}
      {# Constraints are not supported for views. This point in the code should not have been reached. #}
      {{ exceptions.raise_compiler_error("Constraints not supported for views.") }}
    {% elif is_incremental() %}
      {# Constraints are not applied for incremental updates. This point in the code should not have been reached #}
      {{ exceptions.raise_compiler_error("Constraints are not applied for incremental updates. Full refresh is required to update constraints.") }}
    {% else %}
      {#- DIVERGENCE BEGIN: drop any PK inherited from a SHALLOW CLONE before applying
          model constraints. SHALLOW CLONE preserves and renames the source's primary key,
          so a subsequent ALTER TABLE ADD CONSTRAINT fails with "table already has a PRIMARY
          KEY constraint". Upstream dbt-databricks is not affected because it does not use
          SHALLOW CLONE. Only applicable to Unity Catalog (not Hive Metastore).
          Gated on dbt_version: under dbt-core (1.x) SHALLOW CLONE is not used, so no-op. -#}
      {% if dbt_version.startswith('2.') and not relation.is_hive_metastore() %}
        {% set existing_pks = fetch_primary_key_constraints(relation) %}
        {% if existing_pks.rows | length > 0 %}
          {% for row in existing_pks %}
            {% if loop.first %}

View on GitHub (pinned to 0267ce9170)

Solutions

  1. Set `file_format='delta'` in the model config so the constraints can be enforced.
  2. Remove the constraint/contract declarations if the non-delta format is intentional.
  3. Run with `--full-refresh` after switching to delta so the table is recreated in the new format.

Example fix

-- before
{{ config(materialized='table', file_format='parquet', persist_constraints=true) }}
-- after
{{ config(materialized='table', file_format='delta', persist_constraints=true) }}
Defensive patterns

Strategy: validation

Validate before calling

# Validate before running:
if (config.get('persist_constraints') or config.get('contract', {}).get('enforced')) and config.get('file_format') != 'delta':
    raise ValueError('constraints require file_format=delta')

Prevention

When it happens

Trigger: A model with `contract={enforced: true}` or `config.get('persist_constraints')=true` combined with a `file_format` that is not `delta` (e.g. `file_format='parquet'`) in the databricks table materialization.

Common situations: Converting a model from parquet to delta while keeping constraint declarations; copying constraint config into a model that writes external/non-delta tables; org-wide contract enforcement applied to heterogeneous-format models.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of dbt-labs/dbt-core@0267ce9170 (2026-09-07). Data as JSON: /api/errors/29fe93e643e50283. Report an issue: GitHub.