sql - 使用 DBT 创建 Join 查询,但结果省略了一些列
问题描述
我有以下代码使用右连接将我的数据从表 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_id
并incremental_salesorder.name
没有在代码编译成功后的结果中
我在这里做错了什么......?
解决方案
菜鸟错误:
确保定义的模型名称相同:
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
我完全错过了警告。一旦这被纠正,我就能够编译查询并得到我需要的结果。如果有人需要如何进行连接的示例,这是一种工作方法:)
推荐阅读
- sql - 将sql输出转换为以下格式
- dart - 如何在搜索代表中选择用户类型的字母?
- python - 函数列表的并行执行
- python - 如何生成 Q 函数的值
- python - 当我已经安装了 python 3.6 时,如何在运行 python(和 pipenv)2.7 的 pycharm 中设置虚拟环境?
- json - WSO2 ESB / WSO2 EI JSON Request to backend service
- ios - 我在 for 循环中获取值。它正在崩溃
- java - 在 Jersey 2.26 中替换 AbstractContainerRequestValueFactory
- python-3.x - 如何使用 Pandas 从 CSV 文件的日期列中提取特定日期集?
- javascript - How to control Tamper Monkey dashboard Installed script, so that user cannot disable a script