谢谢你提前提供帮助。在jaffle_shop教程中,我使用dbt和am设置源代码。我按照教程的规定设置了所有的东西,直到现在一切都在正常工作。
文件树
jaffle_shop
- models
- marts/core
- dim_customers.sql
- fct_orders.sql
- staging/jaffle_shop
- stg_customers.sql
- stg_orders.sql
- stg_payments.sql
- src_jaffle_shop.yml
- dbt_project.ymlsrc_jaffle_shop.yml看起来如下所示:
version: 2
sources:
- name: jaffle_shop
schema: dbt_jallard
database: dhaus
tables:
- name: customers
- name: orders
- name: payment暂存文件的一个示例是:
with customers as (
select
id as customer_id,
first_name,
last_name
from {{ source('dbt_jallard','customers') }}
-- from dbt_jallard.customers
)
select * from customers 如您所见,我注释掉了常规的sql语句。当使用该语句时,它按预期工作,但当我尝试使用source()引用时,我得到了以下错误:
Model 'model.jaffle_shop.stg_customers' (models/staging/jaffle_shop/stg_customers.sql) depends on a source named 'dbt_jallard.customers' which was not found
数据库配置正确,因为它在从dbt_jallard.customers调用时工作,但由于某种原因,使用{{ source('dbt_jallard','customers') }}会产生此错误。
任何洞察力都会有帮助。谢谢!
发布于 2022-09-08 18:13:12
请将jaffle_shop替换为dbt_jallard作为源yml文件中的名称。
发布于 2022-09-09 07:26:56
您已经在您的jaffle_shop文件中将源命名为“src_jaffle_shop.yml”。dbt中Jinja源引用的语法为{ source(source_name,table_name)}}。因此,此错误消息告诉您,它无法找到source_name dbt_jallard table_name customers的源,因为没有源。
有关更多细节,请查看文档这里。
将您的源引用更改为{ source('jaffle_shop',‘customers’)}将解决您的问题。
发布于 2022-09-08 18:38:34
我必须更改source()函数,以引用源的名称,而不是数据库名。
{{ source("jaffle_shop","customers") }}
https://stackoverflow.com/questions/73653301
复制相似问题