google-bigquery - DBT 从不同的 Google 项目中选择 Big Query 表

标签 google-bigquery dbt

我正在使用 DBT 在 Big Query 中读写表,所有这些都在我的 Google 项目 X 中运行。
我有一个表格,我想从另一个 Google 项目 Y 中读取它并放入 DBT 模型(然后将其保存为项目 X 中的表格)。
可以吗?如果是,我在哪里定义不同的项目 FROM {{ source('dataset_project_y', 'table_to_read')}}

最佳答案

首先,您需要在 source.yml 文件中声明源。

https://docs.getdbt.com/docs/building-a-dbt-project/using-sources#declaring-a-source

比如创建一个source_y.yml

sources:
  - name: dataset_project_y
    schema: dataset_y
    database: 'project_y'
    tables:

      - name: table_to_read
        identifier: table_to_read

在那之后, 您可以在任何 dbt 模型中引用源 table_to_read,在任何 dbt 模型的 SQL 语句中从中选择。

https://docs.getdbt.com/docs/building-a-dbt-project/using-sources#selecting-from-a-source

例如,在dbt_model_x.sql中使用table_to_read

{{
  config(
    materialized = "view",
  )
}}

SELECT * FROM {{ source('dataset_project_y', 'table_to_read')}}

关于google-bigquery - DBT 从不同的 Google 项目中选择 Big Query 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67127662/

相关文章:

docker - 通过 Docker Operator 在 Airflow 中运行 DBT

google-bigquery - 通过 IAM 进行 BigQuery 数据集级访问控制

google-bigquery - BigQuery 标准 SQL 中的 REGEXP_MATCH

dbt - dbt中特定列数据的增量更新

snowflake-cloud-data-platform - 使用 DBT 更改雪花表数据类型

java - 无法在本地运行 GCP DataflowTemplates

google-bigquery - 大查询 : "Clustering encountered a key that is longer than"

python - 没有名为 OpenSSL.crypto 和 ImportError : SignedJwtAssertionCredentials 的模块

jinja2 - 在 dbt 的 Jinja 宏中使用字符串作为参数