dbt 0.13.0 新添加特性sources 试用

dbt 0.13 添加了一个新的功能sources 我呢可以用来做以下事情

  • 从基础模型的源表中进行数据选择
  • 测试对于源数据的假设
  • 计算源数据的freshness

source 操作

  • 定义source 模版格式

    注意对于pg 等类型的,如果包含了schema 的可能需要配置额外参数,或者通过schema 约定

# This example defines a source called `source_1` containing one table
# called `table_1`. This is a minimal example of a source definition.
?
version: 2
?
sources:
  - name: source_1
    tables:
      - name: table_1
      - name: table_2
?
  - name: source_2
    tables:
      - name: table_1
  • schema 配置数据源格式
# This source entry describes the table:
# "raw"."public"."Orders_"
#
# It can be referenced with:
# {{ source(‘ecommerce‘, ‘orders‘) }}
?
version: 2
?
sources:
  - name: ecommerce
    database: raw # Tell dbt to look for the source in the "raw" database
    schema: public # You wouldn‘t put your source data in public, would you?
    tables:
      - name: orders
        identifier: Orders_ # To alias table names to account for strange casing or naming of tables

一个简单例子

我配置的source 直接在model 文件夹中 可以参考https://github.com/rongfengliang/dbt-source-demo,关于表数据结构
也可以参考此项目

  • 环境准备(使用python venv 管理)
python3 -m venv venv 
source venv/bin/activate
pip install dbt
  • 测试数据库准备(使用docker-compose)
version: ‘3.6‘
services:
  postgres:
    image: postgres:9.6.11
    ports: 
    - "5432:5432"
    environment:
    - "POSTGRES_PASSWORD:dalong"
  graphql-engine:
    image: hasura/graphql-engine:v1.0.0-beta.2
    ports:
    - "8080:8080"
    depends_on:
    - "postgres"
    environment:
    - "HASURA_GRAPHQL_DATABASE_URL=postgres://postgres:[email protected]:5432/postgres"
    - "HASURA_GRAPHQL_ENABLE_CONSOLE=true"
    - "HASURA_GRAPHQL_ENABLE_ALLOWLIST=true"
  • model source 配置
models
├── apps
│ ├── app_summary.sql
│ └── sources.yml
└── users
    ├── sources.yml
    ├── user_summary.sql
    └── user_summary2.sql
  • source 内容

    内容很简单,就是配置table

version: 2
sources:
  - name: apps
    schema: public
    tables:
      - name: apps
  • 运行效果
dbt run

效果

Running with dbt=0.13.1
Found 3 models, 0 tests, 0 archives, 0 analyses, 94 macros, 0 operations, 0 seed files, 2 sources
?
17:43:42 | Concurrency: 3 threads (target=‘dev‘)
17:43:42 | 
17:43:42 | 1 of 3 START view model public.app_summary........................... [RUN]
17:43:42 | 2 of 3 START view model public.user_summary.......................... [RUN]
17:43:42 | 3 of 3 START table model public.user_summary2........................ [RUN]
17:43:44 | 2 of 3 OK created view model public.user_summary..................... [CREATE VIEW in 0.26s]
17:43:45 | 1 of 3 OK created view model public.app_summary...................... [CREATE VIEW in 0.27s]
17:43:46 | 3 of 3 OK created table model public.user_summary2................... [SELECT 2 in 0.27s]
17:43:46 | 
17:43:46 | Finished running 2 view models, 1 table models in 4.46s.
?
Completed successfully
?
Done. PASS=3 ERROR=0 SKIP=0 TOTAL=3

参考资料

https://github.com/rongfengliang/dbt-source-demo

原文地址:https://www.cnblogs.com/rongfengliang/p/10988774.html

时间: 2024-07-29 21:48:25

dbt 0.13.0 新添加特性sources 试用的相关文章

在C#6.0中的新语言特性

孙广东    2015.6.5 What's New in C# 6: http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Whats-New-in-C-6 Cross Platform Development系列:http://channel9.msdn.com/Shows/CZSK-videa/Cross-Platform-Development-1-Introduction Developer Productivity: What's

NVIDIA DIGITS 学习笔记(NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0)

转自:http://blog.csdn.net/enjoyyl/article/details/47397505?from=timeline&isappinstalled=0#10006-weixin-1-52626-6b3bffd01fdde4900130bc5a2751b6d1 NVIDIA DIGITS-2.0 + Ubuntu 14.04 + CUDA 7.0 + cuDNN 7.0 + Caffe 0.13.0环境配置 引言 DIGITS简介 DIGITS特性 资源信息 说明 DIGI

Pig升级0.13.0踩过的一个坑

背景:之前的pig版本是0.12,看到社区的0.13.0已经发布好久了,有很多新的patch和feature.其中有一个feature是 设置jar包缓存的参数,pig.user.cache.enabled .这个参数可以提高pig的执行速度.具体看下: https://issues.apache.org/jira/browse/PIG-3954     User Jar Cache     Jars required for user defined functions (UDFs) are

Android 6.0 系统棉花糖新的特性和功能

Get you apps ready for Android 6.0 Marshmallow! 新的功能:运行时的权限提醒,Doze(打盹模式)和备用电源,协助新技术,等等. Android 6.0Changes 伴随着新的特性和功能,Android 6.0(API level 23)在系统上和API的使用上做了一些改变. 如果我们已经发布了一款app,那么就要关注一下这些改变会不会影响应用的运行. RuntimePermissions 这是一种新的权限使用模型,用户可以在程序运行中直接管理应用

Pig安装及简单使用(pig版本0.13.0,Hadoop版本2.5.0)

原文地址:http://www.linuxidc.com/Linux/2014-03/99055.htm 我们用MapReduce进行数据分析.当业务比较复杂的时候,使用MapReduce将会是一个很复杂的事情,比如你需要对数据进行很多预处理或转换,以便能够适应MapReduce的处理模式,另一方面,编写MapReduce程序,发布及运行作业都将是一个比较耗时的事情. Pig的出现很好的弥补了这一不足.Pig能够让你专心于数据及业务本身,而不是纠结于数据的格式转换以及MapReduce程序的编写

【Android 系统开发】CyanogenMod 13.0 源码下载 编译 ROM 制作 ( 手机平台 : 小米4 | 编译平台 : Ubuntu 14.04 LTS 虚拟机)

作者 : 韩曙亮 转载请注明出处 : http://blog.csdn.net/shulianghan/article/details/51592930 手机的两种模式 : 在下面有详细的图片示例; -- Recovery 模式 : 音量键增加 + 电源键, 长按上述组合键, 看到 "MI" 的 LOGO 后即进入 Recovery 模式; -- Fastboot 模式 : 音量键减小 + 电源键, 长按上述组合键, 看到 "FASTBOOT" 后, 即 进入 FA

Hive 0.13 数据类型

hive支持的数据类型路下 数值类型 Numeric Types TINYINT (1字节,数据范围: -128 to 127) SMALLINT (2字节,数据范围: -32,768 to 32,767) INT (4字节,数据范围:-2,147,483,648 to 2,147,483,647) BIGINT (8字节,数据范围: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807) FLOAT (4字节, 单精度浮点数) DOUB

Atitit. C#.net clr 2.0  4.0新特性

Atitit. C#.net clr 2.0  4.0新特性 1. CLR内部结构1 2. CLR 版本发展史3 3. CLR 2.0 3 4. CLR 4 新特性 概览4 4.1.1.  托管与本地代码的互操作5 4.1.2.    垃圾回收6 4.1.3.    代码约定6 4.1.4.    Corrupted state exception6 4.1.5.     新的安全模型7 4.1.6.     同一个进程,多个CLR7 4.1.7.     基本类库7 5. CLR最新发展8 6

Atitit..jdk java 各版本新特性 1.0 1.1 1.2 1.3 1.4 1.5(5.0) 1.6(6.0) 7.0 8.0 9.0 attilax 大总结

Atitit..jdk java 各版本新特性 1.0 1.1 1.2 1.3 1.4 1.5(5.0) 1.6(6.0) 7.0 8.0 9.0 attilax 大总结 1.1. Java的编年史2 1.2. Java版本:JDK 1.02 1.3. Java版本:JDK 1.13 1.4. Java版本:JDK 1.2 (Java 2)4 1.4.1. 1999年5 1.4.2. 2000年5 1.5. Java版本:JDK 1.35 1.5.1. 2001年6 1.5.2. 2002年7