You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

dbt管道中Join报‘非空字段缺失数据’错误的原因与排查

dbt视图关联PostgreSQL报错排查问题

场景说明

我们有两个属于dbt管道的视图,结构如下:

table_a 视图结构

table_a (
  product_id   varchar,
  first_flag   boolean,
  second_flag  boolean
)

table_b 视图结构

table_b (
  transport_id   varchar,
  product_id     varchar,
  some_timestamp timestamp
)

执行的查询语句

尝试执行以下内连接查询:

with _products as (
    select distinct
        product_id
    from
        table_a
    where
        first_flag or
        second_flag
)
select
    transport_id,
    product_id,
    some_timestamp
from
    table_b
    inner join _products using (product_id)

报错信息

执行后触发PostgreSQL错误,且所有连接类型(left、right、full outer等)都会触发相同错误:

postgresql error: Missing data for not-null field DETAIL:
error: Missing data for not-null field code:

已完成的排查

  • 最初推测是dbt管道中存在非空字段被填充NULL或空值的情况,但已确认table_a和table_b中涉及的所有列均无NULL值
  • 通过信息模式核查,两个视图均未配置非空约束

问题

  1. 该错误的成因是什么?
  2. 应如何进一步调试?
  3. 是否有类似问题的已知解决方案?

更新/临时解决方法

将table_a从视图物化为物理表后,问题得以解决,推测该问题可能与dbt的特性相关。


内容的提问来源于stack exchange,提问作者rxFt20

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.29 23:30:11