[v2 问题] 信息模式: node_columns.constraints 和 models.constraints 总是为 NULL,无法用于检查
作者: b-per创建于 2026年10月1日更新于 2026年10月1日
标签type:bugengine:v2v2info schema
dbt_project.yml
name: repro_info_schema_constraints
version: '1.0.0'
profile: repro_info_schema_constraints
model-paths: ["models"]
info_schema:
version: 1profiles.yml
repro_info_schema_constraints:
target: dev
outputs:
dev:
type: duckdb
path: dev.duckdb
threads: 1models/orders.sql
select 1 as order_id, 2 as customer_idmodels/orders.yml
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_nulldbt parse --generate-info-schema(the result is the same afterdbt compile --generate-info-schemaanddbt build --generate-info-schema)- 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
内容来源: dbt-labs/dbt-core