兼容Trino Connector,扩展Apache Doris数据源接入能力|Lakehouse 使用手册(四)

简介: 通过兼容 Connector 插件,Apache Doris 能够支持 Trino/Presto 可对接的所有数据源,而无需改动 Doris 的内核代码。

Apache Doris 内置支持包括 Hive、IcebergHudiPaimon、LakeSoul、JDBC 在内的多种 Catalog,并为其提供原生高性能且稳定的访问能力,以满足与数据湖的集成需求。而随着 Apache Doris 用户的增加,新的数据源连接需求也随之增加。因此,从 3.0 版本开始,Apache Doris 引入了 Trino Connector 兼容框架。

Trino/Presto 作为业界较早应用于湖仓查询、联邦分析的计算引擎,以广泛的数据源对接能力闻名。支持包括 Hive、Iceberg、Hudi、Paimon、Delta Lake、Kudu、BigQuery、Redis、Kafka 在内的数十种数据源,而这一能力主要得益于其插件化的 Connector 框架。Apache Doris 为快速提升数据接入能力与扩展性,并减少对每个数据源支持的开发工作量,选择兼容现有的 Connector 框架是一种高效且合理的解决方案。

通过兼容 Connector 插件,Apache Doris 能够支持 Trino/Presto 可对接的所有数据源,而无需改动 Doris 的内核代码。 该兼容框架不依赖 Trino 服务本身,仅需将编译好的 Connector 插件 JAR 文件部署到 Doris 集群即可使用。对于用户自研的 Connector 插件,也可以快速对接,实现业务平滑迁移。这一结合,为用户提供了更加完善、开放和高性能的查询服务。

目前 Apache Doris 已完成以下 Connector 适配:

Trino Connector 插件兼容方案作为 Apache Doris Catalog 功能的补充,旨在帮助用户快速进行数据源集成和基础的数据迁移,在性能和兼容性方面可能存在不足,欢迎加入社区一同改进。对于 Hive、Iceberg、Hudi、Paimon 等数据源,建议使用 Apache Doris 原生 Catalog 进行访问, 以便于获得最好的性能和稳定性。

本文将帮忙读者快速了解,如何在 Docker 环境下快速搭建 Apache Doris + Apache Delta Lake + Apache Kudu 测试 & 演示环境,并演示如何在 Doris 中适配一个新的 Trino Connector 插件。

使用指南

本文涉及脚本&代码从该地址获取:https://github.com/apache/doris/tree/master/samples/datalake/deltalake_and_kudu

01 环境准备

本文示例采用 Docker Compose 部署,组件及版本号如下:

使用指南-环节准备.png

02 环境部署

1. 创建新的网络

 docker network create -d bridge trinoconnector-net

2. 启动所有组件

sh start-trinoconnector-compose.sh

3. 启动后,可以使用如下脚本,登陆 Doris 命令行

sh login-doris.sh

03 创建 Catalog

登陆 Doris 命令行后,Doris 集群中已创建了名为 delta_lakekudu_catalog 的 Catalog(可通过 SHOW CATALOGS/ SHOW CREATE CATALOG ${catalog_name}查看)。以下为这两个 Catalog 的创建语句:

-- 已创建,无需执行
create catalog delta_lake properties (
  "type"="trino-connector",
  "trino.connector.name"="delta_lake",
  "trino.hive.metastore.uri"="thrift://hive-metastore:9083",
  "trino.hive.s3.endpoint"="http://minio:9000",
  "trino.hive.s3.region"="us-east-1",
  "trino.hive.s3.aws-access-key"="minio",
  "trino.hive.s3.aws-secret-key"="minio123",
  "trino.hive.s3.path-style-access"="true"
);

CREATE CATALOG `kudu_catalog` PROPERTIES (
    "type" = "trino-connector",
    "trino.connector.name" = "kudu",
    "trino.kudu.authentication.type" = "NONE",
    "trino.kudu.client.master-addresses" = "kudu-master-1:7051,kudu-master-2:7151,kudu-master-3:7251"
);

04 数据查询

在启动的 Docker 环境中,可直接在 Doris 集群中查询 Deltalake 和 Kudu 的数据:

查询 Deltalake 表数据

mysql> switch delta_lake;
Query OK, 0 rows affected (0.00 sec)

mysql> use default;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from customer limit 10;
+-----------+--------------------+------------------------------------+-------------+-----------------+-----------+--------------+---------------------------------------------------------------------------------------------------------------+
| c_custkey | c_name             | c_address                          | c_nationkey | c_phone         | c_acctbal | c_mktsegment | c_comment                                                                                                     |
+-----------+--------------------+------------------------------------+-------------+-----------------+-----------+--------------+---------------------------------------------------------------------------------------------------------------+
|         2 | Customer#000000002 | XSTf4,NCwDVaWNe6tEgvwfmRchLXak     |          13 | 23-768-687-3665 |    121.65 | AUTOMOBILE   | l accounts. blithely ironic theodolites integrate boldly: caref                                               |
|        34 | Customer#000000034 | Q6G9wZ6dnczmtOx509xgE,M2KV         |          15 | 25-344-968-5422 |   8589.70 | HOUSEHOLD    | nder against the even, pending accounts. even                                                                 |
|        66 | Customer#000000066 | XbsEqXH1ETbJYYtA1A                 |          22 | 32-213-373-5094 |    242.77 | HOUSEHOLD    | le slyly accounts. carefully silent packages benea                                                            |
|        98 | Customer#000000098 | 7yiheXNSpuEAwbswDW                 |          12 | 22-885-845-6889 |   -551.37 | BUILDING     | ages. furiously pending accounts are quickly carefully final foxes: busily pe                                 |
|       130 | Customer#000000130 | RKPx2OfZy0Vn 8wGWZ7F2EAvmMORl1k8iH |           9 | 19-190-993-9281 |   5073.58 | HOUSEHOLD    | ix slowly. express packages along the furiously ironic requests integrate daringly deposits. fur              |
|       162 | Customer#000000162 | JE398sXZt2QuKXfJd7poNpyQFLFtth     |           8 | 18-131-101-2267 |   6268.99 | MACHINERY    | accounts along the doggedly special asymptotes boost blithely during the quickly regular theodolites. slyly   |
|       194 | Customer#000000194 | mksKhdWuQ1pjbc4yffHp8rRmLOMcJ      |          16 | 26-597-636-3003 |   6696.49 | HOUSEHOLD    | quickly across the fluffily dogged requests. regular platelets around the ironic, even requests cajole quickl |
|       226 | Customer#000000226 | ToEmqB90fM TkLqyEgX8MJ8T8NkK       |           3 | 13-452-318-7709 |   9008.61 | AUTOMOBILE   | ic packages. ideas cajole furiously slyly special theodolites: carefully express pinto beans acco             |
|       258 | Customer#000000258 | 7VbADek8qYezQYotxNUmnNI            |          12 | 22-278-425-9944 |   6022.27 | MACHINERY    | about the regular, bold accounts; pending packages use furiously stealthy warhorses. bold accounts sleep fur  |
|       290 | Customer#000000290 | 8OlPT9G 8UqVXmVZNbmxVTPO8          |           4 | 14-458-625-5633 |   1811.35 | MACHINERY    | sts. blithely pending requests sleep fluffily on the regular excuses. carefully expre                         |
+-----------+--------------------+------------------------------------+-------------+-----------------+-----------+--------------+---------------------------------------------------------------------------------------------------------------+
10 rows in set (0.12 sec)

查询 Kudu 表数据

mysql> switch kudu_catalog;
Query OK, 0 rows affected (0.00 sec)

mysql> use default;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from test_table limit 10;
+------+----------+--------+
| key  | value    | added  |
+------+----------+--------+
|    0 | NULL     | 12.345 |
|    4 | NULL     | 12.345 |
|   20 | NULL     | 12.345 |
|   26 | NULL     | 12.345 |
|   29 | value 29 | 12.345 |
|   42 | NULL     | 12.345 |
|   50 | NULL     | 12.345 |
|   56 | NULL     | 12.345 |
|   66 | NULL     | 12.345 |
|   74 | NULL     | 12.345 |
+------+----------+--------+
10 rows in set (1.49 sec)

联邦查询

mysql> select * from delta_lake.`default`.customer c join kudu_catalog.`default`.test_table t on c.c_custkey = t.`key` where c.c_custkey < 50;
+-----------+--------------------+---------------------------------------+-------------+-----------------+-----------+--------------+--------------------------------------------------------------------------------------------------------+------+----------+--------+
| c_custkey | c_name             | c_address                             | c_nationkey | c_phone         | c_acctbal | c_mktsegment | c_comment                                                                                              | key  | value    | added  |
+-----------+--------------------+---------------------------------------+-------------+-----------------+-----------+--------------+--------------------------------------------------------------------------------------------------------+------+----------+--------+
|         1 | Customer#000000001 | IVhzIApeRb ot,c,E                     |          15 | 25-989-741-2988 |    711.56 | BUILDING     | to the even, regular platelets. regular, ironic epitaphs nag e                                         |    1 | value 1  | 12.345 |
|        33 | Customer#000000033 | qFSlMuLucBmx9xnn5ib2csWUweg D         |          17 | 27-375-391-1280 |    -78.56 | AUTOMOBILE   | s. slyly regular accounts are furiously. carefully pending requests                                    |   33 | value 33 | 12.345 |
|         3 | Customer#000000003 | MG9kdTD2WBHm                          |           1 | 11-719-748-3364 |   7498.12 | AUTOMOBILE   |  deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov |    3 | value 3  | 12.345 |
|        35 | Customer#000000035 | TEjWGE4nBzJL2                         |          17 | 27-566-888-7431 |   1228.24 | HOUSEHOLD    | requests. special, express requests nag slyly furiousl                                                 |   35 | value 35 | 12.345 |
|         2 | Customer#000000002 | XSTf4,NCwDVaWNe6tEgvwfmRchLXak        |          13 | 23-768-687-3665 |    121.65 | AUTOMOBILE   | l accounts. blithely ironic theodolites integrate boldly: caref                                        |    2 | NULL     | 12.345 |
|        34 | Customer#000000034 | Q6G9wZ6dnczmtOx509xgE,M2KV            |          15 | 25-344-968-5422 |   8589.70 | HOUSEHOLD    | nder against the even, pending accounts. even                                                          |   34 | NULL     | 12.345 |
|        32 | Customer#000000032 | jD2xZzi UmId,DCtNBLXKj9q0Tlp2iQ6ZcO3J |          15 | 25-430-914-2194 |   3471.53 | BUILDING     | cial ideas. final, furious requests across the e                                                       |   32 | NULL     | 12.345 |
+-----------+--------------------+---------------------------------------+-------------+-----------------+-----------+--------------+--------------------------------------------------------------------------------------------------------+------+----------+--------+
7 rows in set (0.13 sec)

适配新的 Trino Connector

本小节以 Trino Kafka Connector 插件为例,演示如何在 Doris 中适配 Trino Connector 插件,以及通过 Doris 的 Trino-Connector-Catalog 访问对应数据源。

节选自 Apache Doris 官网文档,完整内容可见:如何接入一个新的 Trino Connector 插件 - Apache Doris

01 编译 Kakfa Connector 插件

Trino 官方并未提供编译好的 Connector 插件,因此需要根据需求自行编译。编译步骤如下:

  • 拉取 Trino 源码: $ git clone https://github.com/trinodb/trino.git
  • 将 Trino 切换至 435 版本: $ git checkout 435
  • 进入 Kafka 插件源码目录: $ cd trino/plugin/trino-kafka
  • 编译 Kafka 插件: $ mvn clean install -DskipTest
  • 编译完成后,trino/plugin/trino-kafka/目录下会生成target/trino-kafka-435目录

注意:

  • 每一个 Connector 插件都是一个子目录,不是 JAR 包。

  • 由于 Doris 当前使用 435 版本的 trino-main 包,建议编译 435 版本的 Connector 插件。其他版本的 Connector 插件可能会存在兼容性问题。如在使用中遇到问题,随时向 Apache Doris 社区反馈。

02 设置 Doris 的 fe.conf / be.conf

Kafka Connector 插件编译完成后,需对 Doris 的 fe.confbe.conf进行配置,使 Doris 能够找到该插件。

首先将上述准备好的 trino-kafka-435 目录存放在 /path/to/connectors 目录下,接着进行配置:

  • fe.conf: 在 fe.conf 文件中配置 trino_connector_plugin_dir=/path/to/connectors (若 fe.conf 中没有配置 trino_connector_plugin_dir 属性,则默认使用 ${Doris_HOME}/fe/connectors 目录)

  • be.conf: 在 be.conf 文件中配置 trino_connector_plugin_dir=/path/to/connectors (若 be.conf 中没有配置 trino_connector_plugin_dir 属性 ,则默认使用 ${Doris_HOME}/be/connectors 目录)

注意:Doris 采用懒加载的方式加载 Trino Connector 插件,这意味着如果第一次在 Doris 中使用 Trino-Connector Catalog 功能,无需重启 FE / BE 节点、Doris 会自动加载插件,且只加载 1 次。而如果 /path/to/connectors/ 目录下插件发生了变化,则需重启 FE / BE 节点,重新加载变化后的插件。

03 使用 Trino-Connector-Catalog 功能

完成前面步骤后,即可在 Doris 中使用 Trino-Connector Catalog 功能。

1. 在 Doris 中创建一个 Trino-Connector Catalog:

  create catalog kafka_tpch properties (
  "type"="trino-connector",
  -- 下面这四个属性来源于 trino,与 trino 的 etc/catalog/kakfa.properties 中的属性一致。
  "trino.connector.name"="kafka",
  "trino.kafka.table-names"="tpch.customer,tpch.orders,tpch.lineitem,tpch.part,tpch.partsupp,tpch.supplier,tpch.nation,tpch.region",
  "trino.kafka.nodes"="localhost:9092",
  "trino.kafka.table-description-dir" = "/mnt/datadisk1/fangtiewei"
  );
  • type关于 Catalog 类型必须设置为trino-connector` ;

  • 属性 trino.connector.nametrino.kafka.table-namestrino.kafka.nodestrino.kafka.table-description-dir 均来源于 Trino,具体可参考:Kafka connector

  • 不同的 Connector 插件应该设置不同的属性,可参考 Trino 官方文档:Connectors

2. 使用 Catalog

创建 Trino-Connector Catalog 后,使用方式与其他 Catalog 完全相同。通过 switch kafka_tpch 语句切换到该 Catalog 后,即可查询 Kafka 数据源中数据。

结束语

后续我们还将陆续推出 Apache Doris 与其他主流数据湖格式、存储系统构建湖仓一体架构的使用指南和方法论,请持续关注。

往期 Lakehouse 使用手册可查阅:

目录
相关文章
|
6月前
|
消息中间件 OLAP Kafka
Apache Doris 实时更新技术揭秘:为何在 OLAP 领域表现卓越?
Apache Doris 为何在 OLAP 领域表现卓越?凭借其主键模型、数据延迟、查询性能、并发处理、易用性等多方面特性的表现,在分析领域展现了独特的实时更新能力。
616 9
|
7月前
|
JSON 关系型数据库 Apache
十亿 JSON 秒级响应:Apache Doris vs ClickHouse,Elasticsearch,PostgreSQL
JSONBench 是一个为 JSON 数据而生的数据分析 Benchmark,在默认设置下,Doris 的性能表现是 Elasticsearch 的 2 倍,是 PostgreSQL 的 80 倍。调优后,Doris 查询整体耗时降低了 74%,对比原榜单第一的 ClickHouse 产品实现了 39% 的领先优势。本文详细描述了调优思路与 Doris 调优前后的性能表现,欢迎阅读了解~
980 0
十亿 JSON 秒级响应:Apache Doris vs ClickHouse,Elasticsearch,PostgreSQL
|
5月前
|
存储 自然语言处理 分布式计算
Apache Doris 3.1 正式发布:半结构化分析全面升级,湖仓一体能力再跃新高
Apache Doris 3.1 正式发布!全面升级半结构化分析,支持 VARIANT 稀疏列与模板化 Schema,提升湖仓一体能力,增强 Iceberg/Paimon 集成,优化存储引擎与查询性能,助力高效数据分析。
747 4
Apache Doris 3.1 正式发布:半结构化分析全面升级,湖仓一体能力再跃新高
|
6月前
|
存储 分布式计算 Apache
湖仓一体:小米集团基于 Apache Doris + Apache Paimon 实现 6 倍性能飞跃
小米通过将 Apache Doris(数据库)与 Apache Paimon(数据湖)深度融合,不仅解决了数据湖分析的性能瓶颈,更实现了 “1+1>2” 的协同效应。在这些实践下,小米在湖仓数据分析场景下获得了可观的业务收益。
1173 9
湖仓一体:小米集团基于 Apache Doris + Apache Paimon 实现 6 倍性能飞跃
|
6月前
|
人工智能 运维 监控
智能运维与数据治理:基于 Apache Doris 的 Data Agent 解决方案
本文基于 Apache Doris 数据运维治理 Agent 展开讨论,如何让 AI 成为 Doris 数据运维工程师和数据治理专家的智能助手,并在某些场景下实现对人工操作的全面替代。这种变革不仅仅是技术层面的进步,更是数据运维治理思维方式的根本性转变:从“被动响应”到“主动预防”,从“人工判断”到“智能决策”,从“孤立处理”到“协同治理”。
1045 11
智能运维与数据治理:基于 Apache Doris 的 Data Agent 解决方案
|
5月前
|
SQL 人工智能 数据挖掘
Apache Doris 4.0 AI 能力揭秘(二):为企业级应用而生的 AI 函数设计与实践
Apache Doris 4.0 原生集成 LLM 函数,将大语言模型能力深度融入 SQL 引擎,实现文本处理智能化与数据分析一体化。通过十大函数,支持智能客服、内容分析、金融风控等场景,提升实时决策效率。采用资源池化管理,保障数据一致性,降低传输开销,毫秒级完成 AI 分析。结合缓存复用、并行执行与权限控制,兼顾性能、成本与安全,推动数据库向 AI 原生演进。
453 0
Apache Doris 4.0 AI 能力揭秘(二):为企业级应用而生的 AI 函数设计与实践
|
6月前
|
SQL 存储 运维
Apache Doris 在菜鸟的大规模湖仓业务场景落地实践
本文介绍了 Apache Doris 在菜鸟的大规模落地的实践经验,菜鸟为什么选择 Doris,以及 Doris 如何在菜鸟从 0 开始,一步步的验证、落地,到如今上万核的规模,服务于各个业务线,Doris 已然成为菜鸟 OLAP 数据分析的最优选型。
423 2
Apache Doris 在菜鸟的大规模湖仓业务场景落地实践
|
8月前
|
人工智能 监控 数据挖掘
6/14 上海,Apache Doris x 阿里云 SelectDB AI 主题线下 Meetup 正式开启报名!
6 月 14 日,由 Apache Doris 社区、飞轮科技、阿里云联合发起的湖仓数智融合、AI 洞见未来:Apache Doris x 阿里云 SelectDB 联合 Meetup 将在上海·汇付天下总部大楼正式开启,邀您一同探索 AI 与数据分析的融合实践!
479 76
|
6月前
|
SQL 存储 JSON
Apache Doris 2.1.10 版本正式发布
亲爱的社区小伙伴们,Apache Doris 2.1.10 版本已正式发布。2.1.10 版本对湖仓一体、半结构化数据类型、查询优化器、执行引擎、存储管理进行了若干改进优化。欢迎大家下载使用。
295 5
|
6月前
|
人工智能 自然语言处理 数据挖掘
Apache Doris 4.0 AI 能力揭秘(一):AI 函数之 LLM 函数介绍
在即将发布的 Apache Doris 4.0 版本中,我们正式引入了一系列 LLM 函数,将前沿的 AI 能力与日常的数据分析相结合,无论是精准提取文本信息,还是对评论进行情感分类,亦或生成精炼的文本摘要,皆可在数据库内部无缝完成。
461 0
Apache Doris 4.0 AI 能力揭秘(一):AI 函数之 LLM 函数介绍

热门文章

最新文章

推荐镜像

更多