簡體   English   中英

使用 DBT 創建 Join 查詢,但結果省略了一些列

[英]Using DBT to create Join queries, but result omits some columns

我有以下代碼使用右連接將我的數據從表 1 連接到表 2。DBT 成功編譯代碼而沒有錯誤,但我沒有得到我需要的列...

{{
  config(
    materialized='incremental'
  )
}}

with incremental_salesorder as (
  select * from {{ source('db_warehouse', 'sale_order_line') }} 
),

final as (
  select 
    distinct incremental_salesorder.product_code_cust, 
    incremental_salesorder.order_id as id,
    incremental_salesorder.create_date, 
    incremental_salesorder.name as product_name, 
    incremental_salesorder.product_name_cust, 
    sale_order.name as sale_order_ref
  from incremental_salesorder 
  right join {{ source('db_warehouse', 'sale_order')}} using (id)
  ORDER BY incremental_salesorder.create_date
)

{% if is_incremental() %}
  where incremental_salesorder.create_date >= (select max(create_date) from {{ this }} )

{% endif %}

select * from final

代碼編譯成功后的結果中沒有incremental_salesorder.order_idincremental_salesorder.name

在此處輸入圖像描述

我在這里做錯了什么......?

菜鳥錯誤:

確保定義的 model 名稱相同:

models:
    dbt_test:
      # Applies to all files under models/example/
        example:
            materialized: view
            +schema: staging
            +enabled: false
        sales_order_unique_incremental: <- this line must match the folder name
            materialized: table
            +schema: datastudio

在此處輸入圖像描述

我完全錯過了警告。 一旦這被糾正,我就能夠編譯查詢並得到我需要的結果。 如果有人需要如何進行連接的示例,這是一種工作方法:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM