在DBT管道中使用外部实木复合地板表

问题描述

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

在我的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表如下:

{{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并返回Error: staging external sources is not implemented for the default adapter。运行dbt run时,我得到Error: UnresolvedRelation datalake.customers

或者也许我可以改用蜂巢元存储库?我将如何解决此问题的任何提示,将不胜感激!

解决方法

此功能可能尚不可用。到目前为止,似乎还没有开发人员来解决。

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

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

这里有一些相关问题:

Spark_connection_url do not contain workspace_id while connecting to databricks

Support Delta Lake format

我意识到在简单的dbt-external-tables用例中并不能完全解决问题,但似乎仍在继续开发支持Azure数据砖/数据湖堆栈的方法。

稍后再尝试深入研究,因为这是一个与我相关的用例。

,

我帮助维护dbt-spark插件和dbt-external-tables软件包。我可以确认他们的互操作性仍处于初步阶段,我强烈欢迎您对其进行改进。我不认为这有什么大的帮助,尽管其中的挑战之一是Spark / Databricks支持两种不同的create external table语法(如that issue中所述)。

首先,我看到您将path/to/storage指定为源的外部位置,并且将location_root模型的orders配置指定为。前者是从 读取数据的地方,后者是将模型实现为表格的地方。我不确定您是要表示相同还是不同的占位符。

编辑:您可以直接在SparkSQL中从某些文件类型中选择select * from filetype.filepath的TIL。我相信您可以注册以下来源:

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`