#16553·dbt-core

[v2 Bug] information schema: node_columns.constraints and models.constraints are always NULL and unavailable to checks

Author: b-perCreated Oct 1, 2026Updated Oct 1, 2026
Labelstype:bugengine:v2v2info schema

Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?

  • I believe this is a new bug in dbt v2.x
  • I have searched the existing issues and could not find a duplicate (closest: #16043, #15850, #15845 — none lists constraints)

Current Behavior

The information schema columns dbt.node_columns.constraints and dbt.models.constraints are always NULL, even for a project that declares column-level and model-level constraints. The same data is present in target/manifest.json, so it is lost between parsing and the information schema, not missing from the project.

The two columns are also not available to checks at all: a check that selects constraints from info_schema('models') or info_schema('node_columns') fails with a binder error, so a check cannot rely on declared constraints.

Expected Behavior

  • node_columns.constraints holds the column's declared constraints (for example the JSON array [{"type":"not_null"}, ...]), and models.constraints holds the model-level constraints.
  • Once populated, constraints is also exposed in the views that checks can query, so a check can use it.

Use case: dbt-project-evaluator 1.x treats a not_null column constraint as equivalent to a not_null test in its "missing primary key tests" rule (a unique test plus a not_null constraint is a tested primary key). A native-check port of that rule cannot reproduce this today, so projects that rely on contracts get false positives.

Steps To Reproduce

dbt_project.yml

yaml
name: repro_info_schema_constraints
version: '1.0.0'
profile: repro_info_schema_constraints
model-paths: ["models"]
info_schema:
  version: 1

profiles.yml

yaml
repro_info_schema_constraints:
  target: dev
  outputs:
    dev:
      type: duckdb
      path: dev.duckdb
      threads: 1

models/orders.sql

sql
select 1 as order_id, 2 as customer_id

models/orders.yml

yaml
models:
  - name: orders
    config:
      contract: {enforced: true}
    constraints:
      - type: primary_key
        columns: [order_id]
    columns:
      - name: order_id
        data_type: int
        constraints:
          - type: not_null
          - type: primary_key
      - name: customer_id
        data_type: int
        constraints:
          - type: not_null
  1. dbt parse --generate-info-schema (the result is the same after dbt compile --generate-info-schema and dbt build --generate-info-schema)
  2. Count the populated values:
    dbt show --inline "select (select count(*) from {{ info_schema('node_columns') }} where constraints is not null) as col_non_null, (select count(*) from {{ info_schema('models') }} where constraints is not null) as model_non_null, (select count(*) from {{ info_schema('node_columns') }}) as n_cols"
    Output: col_non_null = 0, model_non_null = 0, n_cols = 2.
  3. For comparison, target/manifest.json has nodes["model.repro_info_schema_constraints.orders"].constraints (the model-level primary_key) and .columns.order_id.constraints (not_null and primary_key).
  4. Check-time view: add checks/constraints_probe.sql
    sql
    select m.name, m.constraints, c.constraints
    from {{ info_schema('models') }} m
    join {{ info_schema('node_columns') }} c on c.node_unique_id = m.unique_id
    and run dbt check constraints_probe.

Relevant log output

bash
[error] [CheckEvaluationFailed (dbt1653)]: check 'constraints_probe' could not be evaluated:
  Binder Error: Values list "m" does not have a column named "constraints"

What looks like the cause (public source)

Pointers are to dbt-labs/dbt-fusion at 9977b6c (2026-06-04), the most recent public snapshot. I read a newer tree and the logic is the same.

  • crates/dbt-metadata-parquet/src/parse_columns.rs: ParseColumnRow has is_primary_key, constraints (full constraints JSON), meta and granularity, so the parse step does record them.
  • crates/dbt-index-core/src/ingest/metadata_to_parquet.rs, write_parse_columns (~L1627): the row pushed into node_columns only reads unique_id, column_name, declared_type, description and tags; constraints (and meta, granularity) are dropped.
  • The two later merges into node_columns (the catalog and compile column projections, // column_constraints at ~L2177 and ~L2363) write null_str for column_constraints, so nothing fills it afterwards.
  • The model-level reader (node_constraints, read from constraints in the model attributes) is there, but models.constraints is still NULL in the repro, so the value is not reaching that point either.
  • In the newer tree, the parse-time views used by checks leave constraints out, with the comment that no writer fills it. So once the writer is fixed, the column also needs adding to those views.

This looks like another entry for the "columns exposed but never filled" list in #16043. node_columns.meta and granularity appear to be dropped by the same function for the same reason, though I only verified constraints.

Environment

  • OS: macOS
  • CPU: ARM
  • dbt distribution and version: dbt 2.0.6

Which database adapter are you using?

duckdb (not adapter-specific)