目录
1. 为什么会有Presto/Trino
- 1. 为什么会有Presto/Trino
- 2. 使用docker体验Trino
联邦查询: 我们的数据会储存在各种各样的数据库中,以前都需要经过ETL抽取到数据仓库中,现在用Presto/Trino在一条SQL中就能直接查询多个不同数据源实现联邦查询,而且SQL语法兼容大部分HiveQL
性能优化:Presto/Trino支持内存并行处理、跨集群节点管线执行、多线程执行模型、高效的扁平内存数据结构(最小化Java的垃圾回收)、Java字节码生成。超过了Impala和Spark SQL
减少数据仓库层: 可以去除数仓的ODS、DWD层,甚至可以不用DWM层,用Presto/Trino连接各种数据源,直接清洗出DWS大宽表层;而且维度表也可以使用Presto/Trino直接从源数据库读取,并使用Presto/Trino向ADS数据应用层提供服务
2. 使用docker体验Trino运行容器
[root@bigdata001 ~]#
[root@bigdata001 ~]# docker run -d -p 8080:8080 --name trino trinodb/trino:367
Unable to find image 'trinodb/trino:367' locally
367: Pulling from trinodb/trino
2d473b07cdd5: Pull complete
2462392565fe: Pull complete
98b1578c0003: Pull complete
14be6dc9f7ed: Pull complete
c22c8e1c0b45: Pull complete
12be9582c661: Pull complete
Digest: sha256:6899d5bd1c8a0217ed3ecd49e1b47f2fe3ca669373cf50c79a2c8e1116a0b670
Status: Downloaded newer image for trinodb/trino:367
ef299d823fc41aba50c41b1779bdb547d9a305d019c1b31f50e0e2f8e933f6db
[root@bigdata001 ~]#
进入容器连接trino服务器
[root@bigdata001 ~]#
[root@bigdata001 ~]# docker exec -it trino trino --catalog tpch --schema sf1
trino:sf1>
trino:sf1> select count(*) from nation;
_col0
-------
25
(1 row)
Query 20211224_055009_00002_6hihb, FINISHED, 1 node
Splits: 9 total, 9 done (100.00%)
5.22 [25 rows, 0B] [4 rows/s, 0B/s]
trino:sf1>
trino:sf1> help
Supported commands:
QUIT
EXIT
CLEAR
EXPLAIN [ ( option [, ...] ) ]
options: FORMAT { TEXT | GRAPHVIZ | JSON }
TYPE { LOGICAL | DISTRIBUTED | VALIDATE | IO }
DESCRIBE
SHOW COLUMNS FROM
SHOW FUNCTIONS
SHOW CATALOGS [LIKE ]
SHOW SCHEMAS [FROM ] [LIKE ]
SHOW TABLES [FROM ] [LIKE ]
USE [.]
trino:sf1>
trino:sf1> quit
[root@bigdata001 ~]#