dbt 0.14.0 在最近已经发布了,dbt server 的还是很不错的特性,以下安装试用下几个新功能

环境准备

安装

如果没有安装的:
pip install  dbt
已经安装的:
pip install -U dbt

pg 数据库环境准备

使用docker-compose 运行

  • docker-compose 文件
version: "3"
services:
   database:
    image: postgres
    environment:
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "dalong"
    ports:
      - "5432:5432"
   database2:
    image: postgres
    environment:
      POSTGRES_USER: "postgres"
      POSTGRES_PASSWORD: "dalong"
    ports:
      - "5433:5432"

rpc

创建简单项目

  • dbt init
dbt init 14demo
  • 配置profile

    profiles.yml 文件

# For more information on how to configure this file, please see:
# https://github.com/fishtown-analytics/dbt/blob/master/sample.profiles.yml
default:
  target: dev
  outputs:
    dev:
      type: postgres
      host: 127.0.0.1
      user: postgres
      pass: password
      port: 5432
      dbname: postgres
      schema: dalong
      threads: 3
pg:
  target: dev
  outputs:
    dev:
      type: postgres
      host: 127.0.0.1
      user: postgres
      pass: dalong
      port: 5432
      dbname: postgres
      schema: public
      threads: 3
demo:
  target: dev
  outputs:
    dev:
      type: postgres
      host: 127.0.0.1
      user: postgres
      pass: dalong
      port: 5432
      dbname: postgres
      schema: demo
      threads: 3

基本使用

  • 启动pg
docker-compose up -d
  • 启动dbt server rpc 服务
dbt rpc

效果

dbt rpc 
Running with dbt=0.14.0
Found 116 macros, 0 analyses, 0 sources, 0 seed files, 0 snapshots, 0 tests, 1 models, 0 operations
14:39:08 | Concurrency: 3 threads (target='dev')
14:39:08 | 
14:39:08 | Done.
Serving RPC server at 0.0.0.0:8580
Supported methods: ['compile', 'run', 'ps', 'kill']
Send requests to http://localhost:8580/jsonrpc
 
  • rpc 服务请求格式
{
    "jsonrpc": "2.0",
    "method": "{ a valid rpc server command }",
    "id": "{ a unique identifier for this query }",
    "params": {
        "timeout": { timeout for the query in seconds },
        "sql": "{ base64 encoded dbt-sql query }",
        "name": "{ an identifying name for this query }"
    }
}
  • 一个rpc 服务参考例子
{
    "jsonrpc": "2.0",
    "method": "compile",
    "id": "2db9a2fe-9a39-41ef-828c-25e04dd6b07d",
    "params": {
        "timeout": 60,
        "sql": "c2VsZWN0IHt7IDEgKyAxIH19IGFzIGlk",
        "name": "my_first_query"
    }
}
 

curl 格式

curl -X GET \
  http://localhost:8580/jsonrpc \
  -H 'Accept: */*' \
  -H 'Cache-Control: no-cache' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: text/plain' \
  -H 'Host: localhost:8580' \
  -H 'accept-encoding: gzip, deflate' \
  -H 'cache-control: no-cache' \
  -H 'content-length: 229' \
  -H 'cookie: Cookie_6=value; platform=order' \
  -b 'Cookie_6=value; platform=order' \
  -d '{
    "jsonrpc": "2.0",
    "method": "compile",
    "id": "2db9a2fe-9a39-41ef-828c-25e04dd6b07d",
    "params": {
        "timeout": 60,
        "sql": "c2VsZWN0IHt7IDEgKyAxIH19IGFzIGlk",
        "name": "my_first_query"
    }
}'
 

返回数据

{
    "jsonrpc": "2.0",
    "result": {
        "timing": [
            {
                "completed_at": "2019-07-11T06:55:53.542902Z",
                "started_at": "2019-07-11T06:55:53.531315Z",
                "name": "compile"
            },
            {
                "completed_at": "2019-07-11T06:55:53.543440Z",
                "started_at": "2019-07-11T06:55:53.543151Z",
                "name": "execute"
            }
        ],
        "raw_sql": "select {{ 1 + 1 }} as id",
        "compiled_sql": "select 2 as id",
        "logs": [
            {
                "timestamp": "2019-07-11 14:55:53,428",
                "message": "Parsing rpc.my_new_package.my_first_query",
                "levelname": "DEBUG",
                "level": 10
            },
            {
                "timestamp": "2019-07-11 14:55:53,432",
                "message": "Acquiring new postgres connection \"my_first_query\".",
                "levelname": "DEBUG",
                "level": 10
            },
            {
                "timestamp": "2019-07-11 14:55:53,433",
                "message": "Opening a new connection, currently in state init",
                "levelname": "DEBUG",
                "level": 10
            },
            {
                "timestamp": "2019-07-11 14:55:53,522",
                "message": "Found 116 macros, 0 analyses, 0 sources, 1 None, 0 seed files, 0 snapshots, 0 tests, 1 models, 0 operations",
                "levelname": "NOTICE",
                "level": 15
            },
            {
                "timestamp": "2019-07-11 14:55:53,523",
                "message": "Acquiring new postgres connection \"my_first_query\".",
                "levelname": "DEBUG",
                "level": 10
            },
            {
                "timestamp": "2019-07-11 14:55:53,524",
                "message": "Opening a new connection, currently in state init",
                "levelname": "DEBUG",
                "level": 10
            },
            {
                "timestamp": "2019-07-11 14:55:53,531",
                "message": "Compiling rpc.my_new_package.my_first_query",
                "levelname": "DEBUG",
                "level": 10
            }
        ]
    },
    "id": "2db9a2fe-9a39-41ef-828c-25e04dd6b07d"
}

ls 命令

dbt ls

效果:

dbt ls
my_new_package.example.my_first_dbt_model

说明

dbt 0.14.0 的好多新特性还是很不错的

参考资料

https://docs.getdbt.com/docs/rpc
https://docs.getdbt.com/v0.14/docs/run-operation
https://docs.getdbt.com/docs/list
https://github.com/rongfengliang/dbt-0.14.0-learning

dbt 0.14.0 试用的更多相关文章

  1. dbt 0.14.0 发布

    以下内容来自官方博客,新的功能还是很不错的,后边尝试使用下. 参考资料:https://blog.fishtownanalytics.com/dbt-v0-14-0-better-serving-ou ...

  2. npm WARN react-native-maps@0.14.0 requires a peer of react@>=15.4.0 but none was installed

    install  the  react-native     here comes a  questions :: npm WARN react-native@0.41.2 requires a pe ...

  3. 重大更新!Druid 0.18.0 发布—Join登场,支持Java11

    Apache Druid本质就是一个分布式支持实时数据分析的数据存储系统. 能够快速的实现查询与数据分析,高可用,高扩展能力. 距离上一次更新刚过了二十多天,距离0.17版本刚过了三个多月,Druid ...

  4. dbt 0.13.0 新添加特性sources 试用

    dbt 0.13 添加了一个新的功能sources 我呢可以用来做以下事情 从基础模型的源表中进行数据选择 测试对于源数据的假设 计算源数据的freshness source 操作 定义source ...

  5. Adobe Photoshop CC 14.0简体中文特别版32位和64位下载

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  6. iMessenger 2.0.14.0801简述

    有些梦,看似遥不可及.但并非不能实现,仅仅要你足够的强!!.人力有时而穷,所以我们可能还须要一些热心人的帮助.这个人可能就是你. 四年来,我们一直在努力,从未放弃. 在我们做好一件事之前.我们永远不知 ...

  7. error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools":解决方案

    我是在安装scrapy时遇到这个问题的,安装其他组件也可能会遇到.但问题解决办法都是大致相同的. 以安装scrapy为例: 在pycharm中安装twisted时出现: error: Microsof ...

  8. Elasticsearch分布式搜索和数据分析引擎-ElasticStack(上)v7.14.0

    Elasticsearch概述 **本人博客网站 **IT小神 www.itxiaoshen.com Elasticsearch官网地址 https://www.elastic.co/cn/elast ...

  9. 无法解决“Microsoft.SharePoint.Security, Version=15.0.0.0,”与“Microsoft.SharePoint.Security, Version=14.0.0.0”之间的冲突

    VisualStudio 2013创建控制台项目,.NetFramework选为4.5.生成目标平台:x64.然后添加对Microsoft.SharePoint.dll的引用. 生成项目时," ...

随机推荐

  1. ubuntu 使用阿里云镜像源快速搭建kubernetes 1.15.2集群

    一.概述 搭建k8s集群时,需要访问google,下载相关镜像以及安装软件,非常麻烦. 正好阿里云提供了k8s的更新源,国内用户就可以直接使用了. 二.环境介绍 操作系统 主机名 IP地址 功能 配置 ...

  2. Spark实战电影点评系统(二)

    二.通过DataFrame实战电影点评系统 DataFrameAPI是从Spark 1.3开始就有的,它是一种以RDD为基础的分布式无类型数据集,它的出现大幅度降低了普通Spark用户的学习门槛. D ...

  3. emmet css 缩写

    css 缩写 对于CSS语法,Emmet有许多用于属性的预定义代码段.例如,您可以扩展 m 缩写以获取margin: ;代码段. 要获取 margin: 10px;您可以简单地扩展m10缩写. 需要多 ...

  4. 架构 MVC MVP MVVM 简介 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  5. 打印从1到n位数的最大值

    题目: 输入数字n,按顺序打印从1到最大的n位十进制数,如输入3,则打印从1.2.3一直到最大的3位数999 参考大数运算的方法.考虑到位数会很大,所以采用字符串的形式解决.对输入的n,创建一个长度为 ...

  6. 2019年Amazon AWS-Solutions-Architect-Professional考试最新题库(AWS SAP题库)带考试模拟器

    大家好,由于最近自己备考Amazon AWS-Solutions-Architect-Professional考试,购买了以下链接的题库,并通过了考试 https://www.kaoguti.gq/A ...

  7. Tornado + Bootstrap 快速搭建自己的web应用

    前言 最近用 python tordado 框架, 整了一个模板页面, 用于接入与发布数据的展示, tornado 简单易用, bootstrap 比较流行, 用起来也省事, 配合起来做些小案例非常迅 ...

  8. linux限定用户或组对磁盘空间的使用

    实验环境 环境:centos7.3 ,一块磁盘sdb分一个分区sdb1. 安装磁盘配额支持软件 yum install quota 制作文件系统,并以支持配额功能的方式挂载文件系统 mkfs.ext4 ...

  9. 安装VMware14可能出现的问题

    未能提取文件 安装程序未能提取安装vmware workstation所必须的文件 在没有关闭这个弹框的前提下,Win+R输入%temp%,找到以~setup结尾的文件夹,双击下面的临时文件VMwar ...

  10. PL/SQL的结构

    PL/SQL Developer是一个集成开发环境,专门开发面向Oracle数据库的应用.PL/SQL也是一种程序语言,叫做过程化SQL语言(Procedural Language/SQL).PL/S ...