dbt seed 以及base ephemeral使用
seed 可以方便的进行数据的导入,可以方便的进行不变数据(少量)以及测试数据的导入,
base 设置为 ephemeral(暂态),这个同时也是官方最佳实践的建议
项目依赖的gitlab 数据可以参考https://github.com/rongfengliang/graphql-engine-gitlab
参考项目
- 初始化
dbt init gitlab-data
- 配置项目
# Name your package! Package names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: 'gitlab'
version: '1.0'
# This setting configures which "profile" dbt uses for this project. Profiles contain
# database connection information, and should be configured in the ~/.dbt/profiles.yml file
profile: 'default'
# These configurations specify where dbt should look for different types of files.
# The `source-paths` config, for example, states that source models can be found
# in the "models/" directory. You probably won't need to change these!
source-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"] # 可以放seed 数据
macro-paths: ["macros"]
target-path: "target" # directory which will store compiled SQL files
clean-targets: # directories to be removed by `dbt clean`
- "target"
- "dbt_modules"
# You can define configurations for models in the `source-paths` directory here.
# Using these configurations, you can enable or disable models, change how they
# are materialized, and more!
# In this example config, we tell dbt to build all models in the example/ directory
# as views (the default). Try changing `view` to `table` below, then re-running dbt
models:
gitlab:
gitlab:
base:
materialized: ephemeral # base 建议配置为ephemeral
- 模型添加
model/gitlab/base/gitlab_projectinfo.sql:
select * from projects
model/gitlab/transform/gitlab_project_counts.sql:
select * from {{ref('gitlab_projectinfo')}}
profile 配置
~/.dbt/profiles.yml
default:
target: dev
outputs:
dev:
type: postgres
host: 127.0.0.1
user: postgres
pass: password
port: 5432
dbname: gitlabhq_production
schema: public
threads: 3
pg:
target: dev
outputs:
dev:
type: postgres
host: 127.0.0.1
user: postgres
pass: password
port: 5433
dbname: gitlabhq_production
schema: public
threads: 3
运行&&测试&&文档
- 运行
dbt run && dbt seed --show && dbt docs generate && dbt docs serve
- 效果

参考资料
https://github.com/rongfengliang/graphql-engine-gitlab
https://docs.getdbt.com/docs/configuring-models
https://docs.getdbt.com/docs/best-practices
https://docs.getdbt.com/reference#seed
dbt seed 以及base ephemeral使用的更多相关文章
- ACdream 1104 瑶瑶想找回文串(SplayTree + Hash + 二分)
Problem Description 刚学完后缀数组求回文串的瑶瑶(tsyao)想到了另一个问题:如果能够对字符串做一些修改,怎么在每次询问时知道以某个字符为中心的最长回文串长度呢?因为瑶瑶整天只知 ...
- POJ3261-哈希
这个题让求至少出现K次的最大长度的子串,属于最大化最小值问题,首先应该想到二分求字串的长度,二分的过程是O(logN)的,注意judge的时候怎样判断是否满足情况以及满足情况后l,r的变化.可以给每一 ...
- HDOJ--4821--String【弦hash】
联系:http://acm.hdu.edu.cn/showproblem.php?pid=4821 题意:给一个字符串,选m个长度为l的子串组成新的串.要求这m个子串互不同样,问有多少种组合. 字符串 ...
- 矩阵hash + KMP - UVA 12886 The Big Painting
The Big Painting Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=88791 M ...
- (通俗易懂小白入门)字符串Hash+map判重——暴力且优雅
字符串Hash 今天我们要讲解的是用于处理字符串匹配查重的一个算法,当我们处理一些问题如给出10000个字符串输出其中不同的个数,或者给一个长度100000的字符串,找出其中相同的字符串有多少个(这样 ...
- 18.翻译系列:EF 6 Code-First 中的Seed Data(种子数据或原始测试数据)【EF 6 Code-First系列】
原文链接:https://www.entityframeworktutorial.net/code-first/seed-database-in-code-first.aspx EF 6 Code-F ...
- dbt 包依赖简单测试
dbt 包含一个自己的包管理,可以使用git 等工具,还是很方便的,可以方便的进行代码共享,实现复用 创建简单包 实际上就是一个简单的dbt 项目,参考项目 https://gitlab.com/da ...
- dbt 包的构建
dbt的包是一种可以复用的代码,可以方便进行模型的共享 创建一个包 和普通的dbt 项目类似 初始化(init) dbt init [packagename] 目录结构 文件: README.md d ...
- Entity Framework Code-First(19):Seed Data
Seed Database in Code-First: You can insert data into your database tables during the database initi ...
随机推荐
- codeforces 1042d//Petya and Array// Codeforces Round #510 (Div. 2)
题意:给出一个数组,求其中和小于t的区间数. 先计算前缀和数组sum[i].对当前的sum[i],查询树状数组中有几个比(sum[i]-t)大的数,那么用sum[i]减它就是一个合法区间.再将当前的s ...
- android--------Retrofit+RxJava的使用
Retrofit是Square公司开发的一款针对Android网络请求的一个当前很流行的网络请求库. http://square.github.io/retrofit/ https://github. ...
- km板子(二分图最大权匹配)
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast,no-stack- ...
- 基础最短路(模板 dijkstra)
Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路.不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多 ...
- Excel 版本对应
(1) 1985年:Excel 1.0 (2) 1993年:Excel 5.0——Office 4.2 (3) 1995年:Excel 7.0(Excel 95)——Office 95 (4) 199 ...
- 072——VUE中vuex之使用mutations修改购物车仓库数据
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Awk 从入门到放弃(5)– Awk模式(Pattern)之一
转:http://www.zsythink.net/archives/1426
- c#多线程介绍1
一 什么是多线程 1. 什么是进程?一个 exe 运行一次就会产生一个进程,一个 exe 的多个进程之 间数据互相隔离. 2. 一个进程里至少有一个线程:主线程.我们平时写的控制台程序默认就是单线程的 ...
- zabbix项目实践
一,Zabbix生产环境监测案例概述 1.1 项目规划 [x] :主机分组 交换机 Nginx Tomcat MySQL Apache PHP-fpm redis(也有状态页, 自己研究) memca ...
- 链表(list)的实现(c语言)
链表是一种基本的数据结构,今天练习了一下,所以将代码贴在下面,代码测试通过,代码还可以优化,我会过段时间就会增加一部分或者优化一部分直达代码无法优化为止,我的所有数据结构和算法都会用这样的方式在博客上 ...