跳转到主要内容

Singer tap for dbt,使用Singer SDK构建。

项目描述

tap-dbt

PyPI Python versions Singer Test Tap

tap-dbt 是用于 dbt Cloud API v2 的Singer tap。

使用 Singer SDK 构建。

安装

pip install tap-dbt

功能

完整的流元数据可在dbt Labs仓库中找到: openapi_schema

默认选中

如果没有使用目录,以下内容将默认提取

  • 流:账户
  • 流:工作
  • 流:项目
  • 流:运行

可配置

可以在目录中设置 selected 来启用

  • 流:连接
  • 流:环境
  • 流:仓库
  • 流:用户

增量运行流

-finished_at 对运行端点的查询进行排序,即按降序运行完成日期时间,将得到以下内容

id finished_at updated_at created_at
314516 None 2023-05-27 21:05:16.109548+00:00 2023-05-27 21:05:05.664170+00:00
314514 None 2023-05-27 21:00:16.847296+00:00 2023-05-27 21:00:05.458908+00:00
314513 None 2023-05-27 21:00:16.355680+00:00 2023-05-27 21:00:05.427258+00:00
314517 None 2023-05-27 21:05:17.094309+00:00 2023-05-27 21:05:05.696222+00:00
314515 2023-05-27 21:01:28.568431+00:00 2023-05-27 21:01:29.269048+00:00 2023-05-27 21:00:05.488543+00:00
314512 2023-05-27 20:48:59.342035+00:00 2023-05-27 20:48:59.844412+00:00 2023-05-27 20:45:04.509746+00:00
314511 2023-05-27 20:48:46.571106+00:00 2023-05-27 20:48:47.079130+00:00 2023-05-27 20:40:04.257950+00:00
314505 2023-05-27 20:41:35.591976+00:00 2023-05-27 20:41:36.305364+00:00 2023-05-27 20:15:02.808079+00:00
314510 2023-05-27 20:39:27.162437+00:00 2023-05-27 20:39:28.628257+00:00 2023-05-27 20:35:03.939439+00:00
314509 2023-05-27 20:37:39.965974+00:00 2023-05-27 20:37:40.496212+00:00 2023-05-27 20:30:03.802620+00:00

增量同步已经设置为在执行增量同步时在 replication_key = "finished_at" 上工作

  • 如果设置了书签,则按 finished_at 反向顺序查询流。
  • 如果未设置 finished_at 值,则假设运行仍在进行中,因此记录将被包含,并且排序顺序暗示应该有在流中较晚出现的已填充的 finished_at 记录 - 如果 dbt Job 运行仍在进行中,重复同步操作将产生相同的记录,但这遵守“至少一次”的交付承诺 - https://sdk.meltano.com/en/latest/implementation/at_least_once.html
  • 一旦同步操作到达已填充 finished_at 的记录,这些值将与书签进行比较,一旦 finished_at 值小于书签,流将完成同步。

配置

访问 API 文档 了解获取 API 密钥的说明。

您可以使用带有 TAP_DBT_ 前缀的环境外加字段名称的大写字母来传递配置,或使用 JSON 文件

tap-dbt --config=ENV

tap-dbt --config=config.json

输入

字段 描述 类型 必需 默认
api_key dbt Cloud API 的 API 密钥 字符串
account_ids dbt Cloud 账户 ID 字符串列表
user_agent 用于请求的用户代理 字符串 tap-dbt/0.1.0 Singer Tap for the dbt Cloud API
base_url dbt Cloud API 的基本 URL 字符串 https://cloud.getdbt.com/api/v2
page_size 每 API 调用的记录数,设置 limit= URL 参数 整数 5000

通过运行可以获得此 tap 支持的设置和功能的完整列表

tap-dbt --about --format json

JSON示例

{
  "api_key": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "account_ids": ["51341"],
  "user_agent": "tap-dbt/0.1.0 Singer Tap for the dbt Cloud API",
  "base_url": "https://my-dbt-cloud-api.com",
  "page_size": 5000
}

环境变量示例

TAP_DBT_API_KEY=da39a3ee5e6b4b0d3255bfef95601890afd80709
TAP_DBT_ACCOUNT_IDS=51341
TAP_DBT_USER_AGENT='tap-dbt/0.1.0 Singer Tap for the dbt Cloud API'
TAP_DBT_BASE_URL=https://my-dbt-cloud-api.com"
TAP_DBT_PAGE_SIZE=5000

Meltano示例

plugins:
  extractors:
    - name: tap-dbt
      logo_url: https://hub.meltano.com/assets/logos/taps/dbt.png
      label: dbt Cloud
      docs: https://hub.meltano.com/taps/dbt
      repo: https://github.com/edgarrmondragon/tap-dbt
      namespace: dbt
      pip_url: tap-dbt
      executable: tap-dbt
      capabilities:
        - catalog
        - discover
      settings:
        - name: base_url
          label: dbt Cloud URL
          placeholder: "https://cloud.getdbt.com/api/v2"
        - name: api_key
          kind: password
          label: API Key
          docs: "https://docs.getdbt.com/dbt-cloud/api#section/Authentication"
        - name: account_ids
          kind: array
          label: Account IDs
        - name: user_agent
          label: User-Agent
          placeholder: "tap-dbt/0.1.0 Singer Tap for the dbt Cloud API"
        - name: page_size
          kind: integer
          label: Page Size

用法

您可以使用 CLI 或使用 Meltano 轻松运行 tap-dbt

直接执行Tap

tap-dbt --version
tap-dbt --help
tap-dbt --config .secrets/example.json --discover > ./catalog/json

使用Meltano

meltano elt tap-dbt target-snowflake --job_id dbt_snowflake

项目详情


下载文件

下载您平台上的文件。如果您不确定要选择哪个,请了解有关 安装包 的更多信息。

源分布

tap_dbt-0.12.3.post1.tar.gz (14.8 kB 查看哈希值)

上传于 源代码

构建版本

tap_dbt-0.12.3.post1-py3-none-any.whl (15.0 kB 查看哈希值)

上传于 Python 3

由以下支持