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使用的更多相关文章

  1. ACdream 1104 瑶瑶想找回文串(SplayTree + Hash + 二分)

    Problem Description 刚学完后缀数组求回文串的瑶瑶(tsyao)想到了另一个问题:如果能够对字符串做一些修改,怎么在每次询问时知道以某个字符为中心的最长回文串长度呢?因为瑶瑶整天只知 ...

  2. POJ3261-哈希

    这个题让求至少出现K次的最大长度的子串,属于最大化最小值问题,首先应该想到二分求字串的长度,二分的过程是O(logN)的,注意judge的时候怎样判断是否满足情况以及满足情况后l,r的变化.可以给每一 ...

  3. HDOJ--4821--String【弦hash】

    联系:http://acm.hdu.edu.cn/showproblem.php?pid=4821 题意:给一个字符串,选m个长度为l的子串组成新的串.要求这m个子串互不同样,问有多少种组合. 字符串 ...

  4. 矩阵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 ...

  5. (通俗易懂小白入门)字符串Hash+map判重——暴力且优雅

    字符串Hash 今天我们要讲解的是用于处理字符串匹配查重的一个算法,当我们处理一些问题如给出10000个字符串输出其中不同的个数,或者给一个长度100000的字符串,找出其中相同的字符串有多少个(这样 ...

  6. 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 ...

  7. dbt 包依赖简单测试

    dbt 包含一个自己的包管理,可以使用git 等工具,还是很方便的,可以方便的进行代码共享,实现复用 创建简单包 实际上就是一个简单的dbt 项目,参考项目 https://gitlab.com/da ...

  8. dbt 包的构建

    dbt的包是一种可以复用的代码,可以方便进行模型的共享 创建一个包 和普通的dbt 项目类似 初始化(init) dbt init [packagename] 目录结构 文件: README.md d ...

  9. Entity Framework Code-First(19):Seed Data

    Seed Database in Code-First: You can insert data into your database tables during the database initi ...

随机推荐

  1. memcached-1.4.20 主要启动流程笔记

    以下笔记主要是关注tcp模式下memcached的启动过程. main() 设置信号处理函数为sig_handler() 初始化系统设置,保存在全局变量settings里面 settings_init ...

  2. Android之RecyclerView实现时光轴

    做项目的过程中有个需求需要时光轴,于是网上找了部分资料 ,写了个案例,现在分享给大家. 如图: activity_main.xml <?xml version="1.0" e ...

  3. Imbalance Value of a Tree CodeForces - 915F

    链接 大意: 给定树, 求树上所有链上最大值最小值之差 817D的树上版本, 用并查集维护即可. 817D由于是链的情况并查集不必压缩路径即可达到均摊$O(n)$, 该题必须压缩, 复杂度$O(nlo ...

  4. 『Numpy学习指南』排序&索引&抽取函数介绍

    排序: numpy.lexsort(): numpy.lexsort()是个排字典序函数,因为很有意思,感觉也蛮有用的,所以单独列出来讲一下: 强调一点,本函数只接受一个参数! import nump ...

  5. python-day13--装饰器

    1.开放封闭的原则: 1.对扩展是开放的 为什么要对扩展开放呢? 我们说,任何一个程序,不可能在设计之初就已经想好了所有的功能并且未来不做任何更新和修改.所以我们必须允许代码扩展.添加新功能. 2.对 ...

  6. ASP.NET MVC 习惯

  7. 开启turbine收集hystrix指标功能

    使用turbine收集hystrix指标 1.pom中引入对turbin的依赖,并增加dashboard图形界面的展示 <dependencies> <dependency> ...

  8. [LeetCode] 35. Search Insert Position ☆(丢失的数字)

    转载:https://leetcode.windliang.cc/leetCode-35-Search-Insert-Position.html    思路 Given a sorted array ...

  9. PHP:第三章——PHP中嵌套函数和条件函数

    PHP中的嵌套函数: <?php header("Content-Type:text/html;charset=utf-8"); function A(){ echo &qu ...

  10. POJ 1847 dijstra算法

    POJ 无限循环CE中.感觉是读题难.然后就可以建图上模板了. 附个人代码: #include<stdio.h>#include<string.h>#include<io ...