dbt 团队提供了presto 的adapter同时也是一个不错的的参考实现,可以学习

当前dbt presto 对于版本的要求是0.13.1 对于当前最新版本的还不支持,同时需要使用源码安装pip 包

dbt presto pip 包安装

  • clone 代码包
git clone https://github.com/fishtown-analytics/dbt-presto.git
  • pip 开发模式安装
cd dbt-presto
pip install -e .

配置presto profile

  • profiles.yml 文件
my-presto-db:
  target: dev
  outputs:
    dev:
      type: presto
      method: none
      host: <your server ip >
      port: 8080
      database: memory
      schema: default
      threads: 8

demo 项目

  • dbt project 配置

    dbt_project.yml 文件

# 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: 'my_new_package'
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: 'my-presto-db'
# 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"]
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). These settings can be overridden in the individual model files
# using the `{{ config(...) }}` macro.
models:
  my_new_package:
      # Applies to all files under models/example/
      example:
          materialized: view
  • 简单model

    models/example/my_first_dbt_model.sql

-- Welcome to your first dbt model!
-- Did you know that you can also configure models directly within
-- the SQL file? This will override configurations stated in dbt_project.yml
-- Try changing 'view' to 'table', then re-running dbt
{{ config(materialized='table') }}
SELECT * from tpch.tiny.nation

编译&&运行

  • 编译
dbt compile
  • 执行
dbt run
 

效果:

dbt run
Running with dbt=0.13.0-rc1
Found 96 macros, 0 analyses, 0 archives, 0 sources, 0 seed files, 0 tests, 0 operations, 1 models
No handlers could be found for logger "prestodb.transaction"
16:26:09 | Concurrency: 8 threads (target='dev')
16:26:09 | 
16:26:09 | 1 of 1 START table model default.my_first_dbt_model.................. [RUN]
16:26:12 | 1 of 1 OK created table model default.my_first_dbt_model............. [OK in 1.95s]
16:26:12 | 
16:26:12 | Finished running 1 table models in 6.57s.
Completed successfully
Done. PASS=1 ERROR=0 SKIP=0 TOTAL=1

persto server 查询

  • 环境使用的docker 运行
    以下为参考运行脚本
docker run -d -p 8080:8080 --name demo starburstdata/presto
  • 进入容器查询
docker exec -it demo sh
presto-cli
查询table 数据:
use memory.default;
show tables;
       Table
--------------------
 my_first_dbt_model
 nation
(2 rows)
Query 20190711_083342_00134_ucty8, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0:00 [2 rows, 58B] [11 rows/s, 343B/s]
 select * from my_first_dbt_model;
 nationkey | name | regionkey |
-----------+----------------+-----------+---------------------------------------
         0 | ALGERIA | 0 | haggle. carefully final deposits dete
         1 | ARGENTINA | 1 | al foxes promise slyly according to th
         2 | BRAZIL | 1 | y alongside of the pending deposits. c
         3 | CANADA | 1 | eas hang ironic, silent packages. slyl
         4 | EGYPT | 4 | y above the carefully unusual theodoli
         5 | ETHIOPIA | 0 | ven packages wake quickly. regu
         6 | FRANCE | 3 | refully final requests. regular, ironi
         7 | GERMANY | 3 | l platelets. regular accounts x-ray: u
         8 | INDIA | 2 | ss excuses cajole slyly across the pac
         9 | INDONESIA | 2 | slyly express asymptotes. regular dep
        10 | IRAN | 4 | efully alongside of the slyly final de
        11 | IRAQ | 4 | nic deposits boost atop the quickly fi
        12 | JAPAN | 2 | ously. final, express gifts cajole a
        13 | JORDAN | 4 | ic deposits are blithely about the car
        14 | KENYA |

说明

以上是一个简单的集成测试,后边可以学习下源码,看看dbt apdater 的编写

参考资料

https://github.com/fishtown-analytics/dbt-presto
https://docs.getdbt.com/docs/building-a-new-adapter
https://github.com/rongfengliang/dbt-0.14.0-learning
https://www.cnblogs.com/rongfengliang/p/11164355.html
https://github.com/fishtown-analytics/dbt-presto/issues/4
https://github.com/fishtown-analytics/dbt-presto/issues/6

dbt 集成presto试用的更多相关文章

  1. presto-gateway 试用以及docker 镜像制作

    presto-gateway 是 lyft 团队开源 的prestodb 的工具.以下是一个简单的试用,以及碰到问题的解决 还有就是docker 镜像的制作 Dockerfile 很简单,本地构建然后 ...

  2. Maven实战(五)——自己主动化Web应用集成測试

    自己主动化集成測试的角色 本专栏的上一篇文章讲述了Maven与持续集成的一些关系及详细实践,我们都知道,自己主动化測试是持续集成不可缺少的一部分,基本上,没有自己主动化測试的持续集成,都非常难称之为真 ...

  3. wal2json java jdbc 试用

    上边有介绍过使用命令行模式的wal2json扩展使用,以下是一个jdbc 集成的试用(pg jdbc 驱动天然支持复制) 环境准备 pg(包含wal2json扩展)docker-compose 文件 ...

  4. 基于 Apache Hudi 和DBT 构建开放的Lakehouse

    本博客的重点展示如何利用增量数据处理和执行字段级更新来构建一个开放式 Lakehouse. 我们很高兴地宣布,用户现在可以使用 Apache Hudi + dbt 来构建开放Lakehouse. 在深 ...

  5. 基于 Apache Hudi + Presto + AWS S3 构建开放Lakehouse

    认识Lakehouse 数据仓库被认为是对结构化数据执行分析的标准,但它不能处理非结构化数据. 包括诸如文本.图像.音频.视频和其他格式的信息. 此外机器学习和人工智能在业务的各个方面变得越来越普遍, ...

  6. dubbo 转

      http://blog.csdn.net/zhiguozhu/article/details/50517513 背景 随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式 ...

  7. 软件开发V型号

    RAD(rap application development),就是软件开发过程中的一个重要模型,称为高速应用开发模型.其模型构图形似字母V,所以又称V模型.      他通过开发和測试同一时候进行 ...

  8. 还是要精简开发呀,VS2015太大,VS2010不想装

    公司电脑配置没有很好,所以对于我就是一个挑战. vs2015装上了,但是一打开就卡卡卡,基本没法办公. 公布能用记事本吧,太多不方便: Notepad++做辅助的局部修改还是很好用的,装上插件就智能提 ...

  9. Android Weekly Notes Issue #317

    July 8th, 2018 Android Weekly Issue #317 本期主要内容包括"重磅"的Udacity放弃RN(其实是因为他们RN写的那个Feature不要了) ...

随机推荐

  1. linux查看当前路径命令 pwd

    pwd命令能够显示当前所处的路径. 这个命令比较简单,如果有时在操作过程中忘记了当前的路径,则可以通过此命令来查看路径,其执行方式为: # pwd /home/your_username 第一行为运行 ...

  2. docker容器的使用整理

    2019/10/24, docker 19.03.4 摘要:docker容器常用命令整理 gitbooks文档 docker脚本安装 使用官方脚本安装docker,从阿里云下载: curl -fsSL ...

  3. Vue学习之webpack中使用vue(十七)

    一.包的查找规则: 1.在项目根目录中找有没有 node_modules 的文件夹: 2.在 node_modules 中根据包名,找对应的vue 文件夹: 3.在vue 文件夹中,找 一个叫做 pa ...

  4. Mysql中类似于oracle中nvl()函数的ifnull()函数

    IFNULL(expr1,expr2)  如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2.IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境.  my ...

  5. 英文FRAUNCE法国FRAUNCE单词

    France Alternative forms Fraunce In Fraunce, the inhabitants of one city were driven out and forced ...

  6. 使用 shell 脚本配置 iOS 工程

      APP开发过程中,往往需要在多个网络环境或配置中进行切换,以获取不同配置的APP,甚至有时需要用一套代码经过简单的配置生成不同的APP.而手动配置费时费力,且容易出错.这里介绍用脚本工具,去生成不 ...

  7. IDEA修改选取单词颜色和搜索结果的颜色

    一.修改选取单词颜色 下图所示,选取Father后背景为淡蓝色,其它相同单词背景为灰色,根本看不清楚 修改配置 1.修改选取文本背景色为78C9FF 2.修改相同文本背景色为78C9FF,包括iden ...

  8. idea 启动项目报错,more than one fragment with the name [spring web] was found

    这是由于idea导入项目的时候有多个模块,并且有多个web.xml导致的,先删除对应的模块,后启动即可. 另外也有可能是spring的jar冲突,把冲突的jar删除即可.

  9. MySQL备份,使用xtrabackup备份全实例数据时,会造成锁等待吗?那么如果使用mysqldump进行备份呢?

    一.xtrabackup和mysqldump会造成锁等待吗? xtrabackup会,它在备份时会产生短暂的全局读锁FTWL(flush table with read lock),用于拷贝frm/M ...

  10. 部署GitLab时, 问题

    1. 开启防火墙可能会对 nginx 造成影响. 2. 安装 gitlab 会自带一个 nginx, 启动后会对 现有的nginx 造成影响, 解决方案 参考    连接 1