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:dalong@postgres: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
dbt 0.13.0 新添加特性sources 试用的更多相关文章
- 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-we ...
- Pig安装及简单使用(pig版本0.13.0,Hadoop版本2.5.0)
原文地址:http://www.linuxidc.com/Linux/2014-03/99055.htm 我们用MapReduce进行数据分析.当业务比较复杂的时候,使用MapReduce将会是一个很 ...
- thrift接口描述语言 (基于thrift 0.13.0版本)
thrift接口描述语言(IDL)用来定义thrift类型. 一个Thrift IDL文件用来生成各种语言使用的结构体和服务. IDL中包含如下部分: 1. Document Document中包含0 ...
- 【Android 系统开发】CyanogenMod 13.0 源码下载 编译 ROM 制作 ( 手机平台 : 小米4 | 编译平台 : Ubuntu 14.04 LTS 虚拟机)
分类: Android 系统开发(5) 作者同类文章X 版权声明:本文为博主原创文章 ...
- hive-0.12升级成hive 0.13.1
安装了0.12之后,听说0.13.1有许多新的特性,包括永久函数,所以想更新成0.13版的(元数据放在mysql中) 2014年8月5日实验成功 hive0.13.1的新特性 新特性详见 http:/ ...
- CM12.1/13.0编译教程
环境搭建 1.安装64位Ubuntu系统(实体安装.虚拟机安装均可) 注意:要求机器至少4G内存(虚拟机至少分配4G内存),硬盘至少100G空间(源码20G+,编译后整个目录约60~70G) 安装方法 ...
- Oracle 11.2.0.4.0 Dataguard部署和日常维护(3)-Datauard监控篇
1. v$database 查看当前数据库的角色和保护模式 primary库查看 column NAME format a10 column PROTECTION_MODE format a2 ...
- 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. 托管与本地 ...
- Netty 4.0 新的特性及需要注意的地方
Netty 4.0 新的特性及需要注意的地方 这篇文章和你一起过下Netty的主发行版本的一些显著的改变和新特性,让你在把你的应用程序转换到新版本的时候有个概念. 项目结构改变 Netty的包名从or ...
随机推荐
- nodeJs编写的简单服务器
一.简单的nodeJs写的 http 服务器 1.先Hello world,创建最简单的 Node 服务器(server.js) var http = require("http" ...
- 记一次node爬虫经历,手把手教你爬虫
今天业务突然来了个爬虫业务,爬出来的数据以Excel的形式导出,下班前一个小时开始做,加班一个小时就做好了.因为太久没做爬虫了!做这个需求都是很兴奋! 需求说明 访问网站 (循环)获取页面指定数据源 ...
- SpringBoot使用mybatis,发生:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured
最近,配置项目,使用SpringBoot2.2.1,配置mybatis访问db,配好后,使用自定义的数据源.启动发生: APPLICATION FAILED TO START ************ ...
- The driver is automatically registered via the SPI and manual loading of the driver class....
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdb ...
- C# vb .net实现宝丽来效果滤镜
在.net中,如何简单快捷地实现Photoshop滤镜组中的宝丽来效果呢?答案是调用SharpImage!专业图像特效滤镜和合成类库.下面开始演示关键代码,您也可以在文末下载全部源码: 设置授权 第一 ...
- flask与Flask-CORS的使用
flask与Flask-CORS的使用 一.安装 pip install flask-cors 二.使用 # 文件:manage.py from flask_cors import CORS from ...
- Jmeter:内存配置 -- 转发
在压测过程中jmeter报内存溢出,可能的原因有很多.要注意下面三点: 1.单击压测过程中使用过多的线程,官网建议1000-2000.具体看机器的配置和启动应用的情况.(A single JMeter ...
- 小div在大div中垂直居中方式
代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8 ...
- Oracle与SQL Server等数据库的区别
Oracle与SQL Server等数据库的区别 在Oracle中提倡使用一个连接 Oracle处理多个并发语句使用一个连接,大大提升系统能支持的并发量 Oracle运行在32为单进程平台上SGA和P ...
- v8--sort 方法 源码 (2) 快速排序法
v8 sort方法部分关于快速排序法的源码: function QuickSort(a, from, to) { // Insertion sort is faster for short array ...