在 DBT 管道中使用外部镶木地板表

Using external parquet tables in a DBT pipeline

我正在尝试设置一个简单的 DBT 管道,该管道使用存储在 Azure Data Lake Storage 上的镶木地板 tables 并创建另一个 tables 也将存储在相同的位置。

在我的 models/(定义为我的源路径)下,我有 2 个文件 datalake.ymlorders.sqldatalake.yml 看起来像这样:

version:2
sources:
   - name: datalake
     tables:
        - name: customers
          external:
             location: path/to/storage1 # I got this by from file properties in Azure
             file_format: parquet
          columns:
             - name: id
               data_type: int
               description: "ID"
             - name: ...

我的 orders.sql table 看起来像这样:

{{config(materialized='table', file_format='parquet', location_root='path/to/storage2')}}
select name, age from {{ source('datalake', 'customers') }}

我也在使用 dbt-external-tables 包。另请注意,当我 运行 dbt debug 一切正常时,我可以连接到我的数据库(恰好是 Databricks)。

我尝试了 运行宁 dbt run-operation stage_external_sources 哪个 returns Error: staging external sources is not implemented for the default adapter。当我 运行 dbt run 时,我得到 Error: UnresolvedRelation datalake.customers.

或者也许我可以改用 hive metastore?非常感谢任何有关如何解决此问题的提示!

这可能还不可用。看起来它仍然是一个悬而未决的问题,到目前为止还没有开发工作。

dbt-external-tables 包回购的相关问题:Support Spark external tables

您是否安装了 dbt-spark 的依赖项?

这里有一些相关的问题:

Spark_connection_url 连接到数据块时不包含 workspace_id

Support Delta Lake format

我意识到这些对于简单 dbt-external-tables use-case 并没有完全帮助,但看起来开发仍在 on-going 以支持 azure databricks / datalake 堆栈。

稍后会尝试深入研究这个问题,因为这 use-case 也与我相关。

我帮助维护 dbt-spark 插件和 dbt-external-tables 包。我可以确认它们的互操作性仍处于初步阶段,我 强烈 欢迎贡献来改​​进它。我不认为这是一个很大的提升,尽管挑战之一是 Spark/Databricks 支持两种不同的 create external table 语法(如 that issue 中所述)。

FWIW 我看到您将 path/to/storage 指定为源 orders 模型的 location_root 配置的外部位置。前者是从中读取数据的地方,后者是将模型具体化为table的地方。我不确定你的意思是代表相同的占位符还是不同的占位符。

编辑: 直到您可以 select 直接在 SparkSQL 中从某些文件类型 select * from filetype.filepath。我相信您可以像这样注册一个来源:

version:2
sources:
 - name: datalake
   schema: parquet
   tables:
     - name: customers
       identifier: "path/to/storage1"
       quoting:
         identifier: true

这意味着您可以使用如下模板代码:

select * from {{ source('datalake', 'customers') }}

这将解析为:

select * from parquet.`path/to/storage1`