客户使用trino进行开发,且希望使用trino433版本,但由于原版trino不支持达梦数据库,达梦的trino插件现有版本并不支持trino433,所以需要我们进行适配
这里需要说明的是,因为我毕竟不是开发,所以并不是从零开始做的trino插件,而是根据老版本的trino-dameng插件源码修改后进行适配
| 名称 | 版本/类型 |
|---|---|
| 操作系统 | kylin10SP3 |
| CPU | x86架构64位 |
| JDK | zulu17.42.21 |
| Maven | maven3.6.3 |
| Trino | trino433 |
| DM数据库 | 达梦9/达梦8均可 |
先下载trino的前置依赖,trino依赖jdk和maven,需要进行下载。需要注意不同版本的trino对相关依赖要求的版本不一样,比如433版本trino要求使用jdk17,之后的版本可能要求使用更新的jdk版本
先下载jdk,这里以433版本为例,trino推荐64位系统使用Azul Zulu版本的jdk,下载地址: https://www.azul.com/downloads/#zulu
打开页面下滑,选择java17、linux、x86架构64bit,选择jdk包,点击download选择tar.gz下载

将这个jdk添加到path中方便使用
# 创建jdk目录
[root@localhost bin]# mkdir /linux_soft
# 这里已经将jdk文件放进该目录,查看一下当前目录有什么
[root@localhost bin]# ll /linux_soft
总用量 193496
-rw-r--r-- 1 root root 198138085 7月 27 11:14 zulu17.68.17-ca-jdk17.0.20-linux_4.tar.gz
# 需要解压,将解压后的jdk文件夹放到linux_soft目录下,建议对解压后的文件夹重命名,这里重命名为jdk17
[root@localhost linux_soft]# tar -zxvf zulu17.68.17-ca-jdk17.0.20-linux_x64.tar.gz
[root@localhost linux_soft]# mv zulu17.68.17-ca-jdk17.0.20-linux_x64 jdk17
# 修改配置文件
[root@localhost linux_soft]# vi /etc/profile
# 写入如下内容
export JAVA_HOME=/linux_soft/jdk17
export PATH=$JAVA_HOME/bin:$PATH
#让修改的配置文件立刻生效
[root@localhost linux_soft]# source /etc/profile
#查询版本
[root@localhost linux_soft]# /linux_soft/jdk17/bin/java -version
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Zulu17.68+17-CA (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.68+17-CA (build 17.0.20+8-LTS, mixed mode, sharing)
#看一下path是否配置成功了
[root@localhost linux_soft]# java -version
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Zulu17.68+17-CA (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.68+17-CA (build 17.0.20+8-LTS, mixed mode, sharing)
在官方下载地址下载: https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip
配置maven
#将解压后的manven文件夹放到linux_soft下
[root@localhost linux_soft]# ls
apache-maven-3.6.3-bin.zip jdk17
[root@localhost linux_soft]# unzip apache-maven-3.6.3-bin.zip
Archive: apache-maven-3.6.3-bin.zip
【解压输出略】
[root@localhost linux_soft]# ls
apache-maven-3.6.3 apache-maven-3.6.3-bin.zip jdk17
# 配置maven路径
[root@localhost linux_soft]# vi /etc/profile
# 写入如下内容
export JAVA_HOME=/linux_soft/jdk17
export MAVEN_HOME=/linux_soft/apache-maven-3.6.3
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
# 使修改过的配置立刻生效
[root@localhost linux_soft]# source /etc/profile
# 查看mvn版本是否正确
[root@localhost linux_soft]# mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /linux_soft/apache-maven-3.6.3
Java version: 17.0.20, vendor: Azul Systems, Inc., runtime: /linux_soft/jdk17
Default locale: zh_CN, platform encoding: UTF-8
OS name: "linux", version: "4.19.90-89.11.v2401.ky10.x86_64", arch: "amd64", family: "unix"
修改settings.xml
#创建本地仓库目录
[root@localhost linux_soft]# mkdir /linux_soft/apache-maven-3.6.3/repo
[root@localhost linux_soft]# vi /linux_soft/apache-maven-3.6.3/conf/settings.xml
写入或修改如下内容:
<localRepository>/linux_soft/apache-maven-3.6.3/repo</localRepository>
<!-- 修改镜像源地址 -->
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
在trino的pom.xml里加入如下内容指定国内镜像源
<repositories> <repository> <id>aliyun1</id> <url>https://maven.aliyun.com/repository/public/</url> </repository> <repository> <id>aliyun2</id> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> </repository> <repository> <id>tencent1</id> <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url> </repository> <repository> <id>gw1</id> <url>http://search.maven.org</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>tencent</id> <url>https://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url> </pluginRepository> </pluginRepositories>
在官方github下载trino433版本源码: https://github.com/trinodb/trino/archive/refs/tags/433.tar.gz
修改limits.conf文件以修改资源限制
vim /etc/security/limits.conf
写入如下内容
trino soft nofile 131072
trino hard nofile 131072
trino soft nproc 128000
trino hard nproc 128000
新建一个目录存放相关文件,解压trino源码
[root@localhost linux_soft]# mkdir /trino_src [root@localhost linux_soft]# cd /trino_src [root@localhost trino_src]# ls trino-433.tar.gz [root@localhost trino_src]# tar -zxf trino-433.tar.gz [root@localhost trino_src]# ls trino-433 trino-433.tar.gz [root@localhost trino_src]# cd trino-433/
需要注意,下载的tar.gz包里没有.git目录,不存在git信息,导致一个需要git信息的插件无法无法编译,于是在这里自己init了一下
git init -b main git add .gitignore git commit -m "ignore" git add . git commit -m "first"
开始构建,需要注意第一次构建时需要下载很多包,对网速需求比较高
[root@localhost trino-433]# ./mvnw install -DskipTests -rf :trino-testing-services -pl '!docs'
编译的时候可以用下列参数加快构建
-pl '!docs':排除非必需的docs模块-DskipTests=true:跳过测试,能节省构建时间,但容易导致无法发现代码中的潜在问题-DfailIfNoTests=false:防止因某些模块没有测试用例而构建失败-rf :trino-testing-services命令表示从上次失败的某个模块(这里是trino-testing-services)的位置继续,用于加快构建等待编译完成
下载idea linux版本,解压出来用
[root@localhost ~]# sudo tar -zxvf ~/idea-2026.2.0.1.tar.gz -C /linux_soft/ [root@localhost ~]# cd /linux_soft/ [root@localhost linux_soft]# ls apache-maven-3.6.3 apache-maven-3.6.3-bin.zip idea-IU-262.8665.337 jdk17 [root@localhost linux_soft]# mv idea-IU-262.8665.337 idea [root@localhost linux_soft]# ls apache-maven-3.6.3 apache-maven-3.6.3-bin.zip idea jdk17
用idea打开项目

按照该结构创建/修改相关配置文件
/trino_src/trino-433/testing/trino-server-dev/etc
|-->node.properties
|-->jvm.config
|-->config.propoerties
|-->log.propoerties
|-->catalog
|-->testmysql.properties
|-->dameng.properties
配置node.properties
[root@localhost bin]# cd /trino_src/trino-433/testing/trino-server-dev/etc [root@localhost etc]# mkdir /trino_src/trino_data [root@localhost etc]# vim node.properties 写入: node.environment=production node.id=ffffffff-ffff-ffff-ffff-ffffffffffff node.data-dir=/trino_src/trino_data
配置jvm.config
[root@localhost etc]# vim jvm.config
写入:
-server
-Xmx4G
-XX:InitialRAMPercentage=80
-XX:MaxRAMPercentage=80
-XX:G1HeapRegionSize=32M
-XX:+ExplicitGCInvokesConcurrent
-XX:+ExitOnOutOfMemoryError
-XX:+HeapDumpOnOutOfMemoryError
-XX:-OmitStackTraceInFastThrow
-XX:ReservedCodeCacheSize=512M
-XX:PerMethodRecompilationCutoff=10000
-XX:PerBytecodeRecompilationCutoff=10000
-Djdk.attach.allowAttachSelf=true
-Djdk.nio.maxCachedBufferSize=200000
-XX:+UnlockDiagnosticVMOptions
-XX:+UseAESCTRIntrinsics
# Disable Preventive GC for performance reasons (JDK-8293861)
-XX:-G1UsePreventiveGC
配置config.properties
[root@localhost etc]# vim config.properties 写入: http-server.http.port=8080 discovery.uri=http://localhost:8080 exchange.http-client.max-connections=1000 exchange.http-client.max-connections-per-server=1000 exchange.http-client.connect-timeout=1m exchange.http-client.idle-timeout=1m scheduler.http-client.max-connections=1000 scheduler.http-client.max-connections-per-server=1000 scheduler.http-client.connect-timeout=1m scheduler.http-client.idle-timeout=1m query.client.timeout=5m query.min-expire-age=30m plugin.bundles=\ ../../plugin/trino-resource-group-managers/pom.xml,\ ../../plugin/trino-password-authenticators/pom.xml, \ ../../plugin/trino-iceberg/pom.xml,\ ../../plugin/trino-delta-lake/pom.xml,\ ../../plugin/trino-blackhole/pom.xml,\ ../../plugin/trino-cassandra/pom.xml,\ ../../plugin/trino-memory/pom.xml,\ ../../plugin/trino-jmx/pom.xml,\ ../../plugin/trino-raptor-legacy/pom.xml,\ ../../plugin/trino-hive-hadoop2/pom.xml,\ ../../plugin/trino-hudi/pom.xml,\ ../../plugin/trino-example-http/pom.xml,\ ../../plugin/trino-kafka/pom.xml, \ ../../plugin/trino-tpch/pom.xml, \ ../../plugin/trino-local-file/pom.xml, \ ../../plugin/trino-mysql/pom.xml,\ ../../plugin/trino-mariadb/pom.xml,\ ../../plugin/trino-singlestore/pom.xml,\ ../../plugin/trino-sqlserver/pom.xml, \ ../../plugin/trino-prometheus/pom.xml, \ ../../plugin/trino-postgresql/pom.xml, \ ../../plugin/trino-thrift/pom.xml, \ ../../plugin/trino-tpcds/pom.xml, \ ../../plugin/trino-google-sheets/pom.xml, \ ../../plugin/trino-druid/pom.xml, \ ../../plugin/trino-geospatial/pom.xml, \ ../../plugin/trino-http-event-listener/pom.xml, \ ../../plugin/trino-exchange-filesystem/pom.xml, \ ../../plugin/trino-exchange-hdfs/pom.xml, \ ../../plugin/trino-mysql-event-listener/pom.xml node-scheduler.include-coordinator=true
新建log.properties
[root@localhost etc]# vim log.properties
写入:
io.trino=INFO
# show classpath for plugins
io.trino.server.PluginManager=DEBUG
# Maven plugin loading code
com.ning.http.client=WARN
配置mysql数据源
#在etc目录下新建catalog目录 存放数据源
[root@localhost etc]# mkdir -p /trino_src/trino-433/testing/trino-server-dev/etc/catalog
[root@localhost etc]# cd catalog/
[root@localhost catalog]# vim testmysql.properties
写入:
connector.name=mysql
connection-url=jdbc:mysql://localhost:3306
connection-user=root
connection-password=Maria123
修改DevelopmentServer类的配置

虚拟机选项:
-ea -XX:+UseG1GC -XX:G1HeapRegionSize=32M -XX:+UseGCOverheadLimit -XX:+ExplicitGCInvokesConcurrent -Xmx2G -Dconfig=etc/config.properties -Dlog.levels-file=etc/log.properties
工作目录:
$MODULE_DIR$
修改后,运行成功,可以在 http://localhost:8080/ui/login.html 打开,默认账号admin,没有密码

确认一下是否编译出trino-cli-*-executable.jar,使用jar包进行测试
[root@localhost trino-433]# ls -l /trino_src/trino-433/client/trino-cli/target/trino-cli-*-executable.jar -rwx--x--x 1 root root 13935813 7月 27 15:32 /trino_src/trino-433/client/trino-cli/target/trino-cli-433-executable.jar
[root@localhost trino-433]# java -jar /trino_src/trino-433/client/trino-cli/target/trino-cli-433-executable.jar --server localhost:8080
trino> CREATE SCHEMA testmysql.test_decimal;
CREATE SCHEMA
trino> CREATE TABLE testmysql.test_decimal.test_decimal (delta DECIMAL(10, 5));
->
CREATE TABLE
trino> INSERT INTO testmysql.test_decimal.test_decimal VALUES (12345.06789);
->
INSERT: 1 row
Query 20260728_062912_00008_w3pr4, FINISHED, 1 node
Splits: 19 total, 19 done (100.00%)
0.60 [0 rows, 0B] [0 rows/s, 0B/s]
trino> SELECT * FROM testmysql.test_decimal.test_decimal;
->
delta
-------------
12345.06789
(1 row)
Query 20260728_062921_00009_w3pr4, FINISHED, 1 node
Splits: 1 total, 1 done (100.00%)
0.24 [1 rows, 0B] [4 rows/s, 0B/s]
trino>
测试连接成功
添加导入trino-dameng模块,这里用的是435版本进行修改
[root@localhost trino-433]# cd /root [root@localhost ~]# ls 公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg 模板 图片 下载 桌面 idea-2026.2.0.1.tar.gz trino-dameng.zip [root@localhost ~]# unzip trino-dameng.zip 【解压过程略】 [root@localhost ~]# ls 公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg trino_src 模板 图片 下载 桌面 idea-2026.2.0.1.tar.gz trino-dameng.zip [root@localhost ~]# mv trino_src/trino-435/plugin/trino-dameng /trino_src/trino-433/plugin/ [root@localhost ~]# ls /trino_src/trino-433/trino-dameng 1.txt pom.xml src
修改trino-dameng模块的pom.xml为trino框架的实际版本,此处是433

修改达梦驱动版本,pom中内置的8.1.2.192驱动,这里按需调整为8.1.5.45

修改为
<!-- Source: https://mvnrepository.com/artifact/com.dameng/DmJdbcDriver8 -->
<dependency>
<groupId>com.dameng</groupId>
<artifactId>DmJdbcDriver8</artifactId>
<version>8.1.5.45</version>
<scope>compile</scope>
</dependency>
修改根的pom.xml文件,添加trino-dameng的文件,这行一定要放到trino-c开头的最后一个模块后面,不然后面编译不通过(可以用命令自动调整顺序)
mvn com.github.ekryd.sortpom:sortpom-maven-plugin:3.3.0:sort

在dependency中添加达梦的依赖,这部分一定要放到trino-c开头的最后一个模块后面(这里trino-dameng模块弄错了顺序,但内容是对的)

屏蔽掉语法检查,不然多个空格少个空格都报错

修改trino-server模块的trino.xml文件

修改config.properties文件的插件部分

重新编译
[root@localhost trino-433]# cd /trino_src/trino-433 [root@localhost trino-433]# ./mvnw -pl '!docs' clean install -DskipTests=true -DfailIfNoTests=false
如果编译出错,修改后可以使用-rf :trino-dameng指定从dameng模块继续编译(其他模块也类似)
编译成功
[INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary for trino-dameng 433: [INFO] [INFO] trino-dameng ....................................... SUCCESS [ 22.698 s] [INFO] trino-jmx .......................................... SUCCESS [ 7.085 s] [INFO] trino-testing-resources ............................ SUCCESS [ 2.461 s] [INFO] trino-delta-lake ................................... SUCCESS [ 52.769 s] [INFO] trino-druid ........................................ SUCCESS [ 6.083 s] [INFO] trino-elasticsearch ................................ SUCCESS [ 9.479 s] [INFO] trino-example-http ................................. SUCCESS [ 3.951 s] [INFO] trino-example-jdbc ................................. SUCCESS [ 3.820 s] [INFO] trino-exchange-hdfs ................................ SUCCESS [ 13.504 s] [INFO] trino-geospatial ................................... SUCCESS [ 12.774 s] [INFO] trino-google-sheets ................................ SUCCESS [ 4.880 s] [INFO] trino-http-event-listener .......................... SUCCESS [ 3.433 s] [INFO] trino-hudi ......................................... SUCCESS [ 29.027 s] [INFO] trino-iceberg ...................................... SUCCESS [ 45.878 s] [INFO] trino-ignite ....................................... SUCCESS [ 5.936 s] [INFO] trino-testing-kafka ................................ SUCCESS [ 2.104 s] [INFO] trino-kafka ........................................ SUCCESS [ 11.965 s] [INFO] trino-kinesis ...................................... SUCCESS [ 7.053 s] [INFO] trino-kudu ......................................... SUCCESS [ 7.344 s] [INFO] trino-local-file ................................... SUCCESS [ 3.548 s] [INFO] trino-mariadb ...................................... SUCCESS [ 5.039 s] [INFO] trino-ml ........................................... SUCCESS [ 5.340 s] [INFO] trino-mongodb ...................................... SUCCESS [ 6.527 s] [INFO] trino-mysql ........................................ SUCCESS [ 6.059 s] [INFO] trino-mysql-event-listener ......................... SUCCESS [ 3.497 s] [INFO] trino-oracle ....................................... SUCCESS [ 7.836 s] [INFO] trino-phoenix5 ..................................... SUCCESS [ 17.256 s] [INFO] trino-pinot ........................................ SUCCESS [ 18.583 s] [INFO] trino-postgresql ................................... SUCCESS [ 6.149 s] [INFO] trino-prometheus ................................... SUCCESS [ 5.029 s] [INFO] trino-raptor-legacy ................................ SUCCESS [ 15.516 s] [INFO] trino-redis ........................................ SUCCESS [ 6.040 s] [INFO] trino-redshift ..................................... SUCCESS [ 5.981 s] [INFO] trino-resource-group-managers ...................... SUCCESS [ 6.351 s] [INFO] trino-session-property-managers .................... SUCCESS [ 6.483 s] [INFO] trino-singlestore .................................. SUCCESS [ 4.185 s] [INFO] trino-sqlserver .................................... SUCCESS [ 5.448 s] [INFO] trino-teradata-functions ........................... SUCCESS [ 2.368 s] [INFO] trino-thrift-testing-server ........................ SUCCESS [ 19.051 s] [INFO] trino-thrift ....................................... SUCCESS [ 5.031 s] [INFO] trino-proxy ........................................ SUCCESS [ 5.311 s] [INFO] trino-verifier ..................................... SUCCESS [ 11.120 s] [INFO] trino-benchmark-queries ............................ SUCCESS [ 0.663 s] [INFO] trino-benchto-benchmarks ........................... SUCCESS [ 45.157 s] [INFO] trino-tests ........................................ SUCCESS [ 14.262 s] [INFO] trino-faulttolerant-tests .......................... SUCCESS [ 4.882 s] [INFO] trino-plugin-reader ................................ SUCCESS [ 24.588 s] [INFO] trino-product-tests ................................ SUCCESS [01:42 min] [INFO] trino-product-tests-launcher ....................... SUCCESS [ 38.783 s] [INFO] trino-server-dev ................................... SUCCESS [ 3.717 s] [INFO] trino-test-jdbc-compatibility-old-driver ........... SUCCESS [ 1.667 s] [INFO] trino-test-jdbc-compatibility-old-server ........... SUCCESS [ 1.405 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 11:10 min [INFO] Finished at: 2026-07-29T10:28:01+08:00 [INFO] ------------------------------------------------------------------------ [root@localhost trino-433]#
添加配置文件
[root@localhost catalog]# pwd /trino_src/trino-433/testing/trino-server-dev/etc/catalog [root@localhost catalog]# cat dameng.properties connector.name=dameng connection-url=jdbc:dm://localhost:5236 connection-user=SYSDBA connection-password=Dameng123
[root@localhost target]# java -jar trino-cli-433-executable.jar --server http://localhost:8080
trino> SHOW CATALOGS;
Catalog
---------
dameng
system
(2 rows)
Query 20260729_032947_00000_v86sj, FINISHED, 1 node
Splits: 11 total, 11 done (100.00%)
1.78 [0 rows, 0B] [0 rows/s, 0B/s]
可以连接达梦数据库,开始测试trino能否创建对应列以及读取到达梦创建的列
测试步骤
先drop旧的同名表,然后按以下两种顺序测试
需要验证的类型:BLOB、CLOB、浮点数(float、real、double)、number、decimal、timestamp
需要注意,达梦数据库内的blob对应trino的varbinary
为了测试trino是否能正常读取disql创建的表以及trino是否能正常创建和插入数据,这里先后使用disql和trino建表、插入数据,然后在另一侧查看表结构和插入的数据,验证是否正常
先在disql中建表,需要注意在disql中记得commit,否则可能出现在disql中能看到插入的数据,但在trino中看不到的情况
SQL>
DROP TABLE IF EXISTS SYSDBA.TEST_BLOB;
CREATE TABLE SYSDBA.TEST_BLOB (
id INT,
name VARCHAR(100),
BlobContent BLOB,
description VARCHAR(500)
);
DESC SYSDBA.TEST_BLOB;
INSERT INTO SYSDBA.TEST_BLOB (id, name, BlobContent, description) VALUES
(1, '测试图片1', '0x89504E470D0A1A0A0000000D49484452', 'PNG文件头'),
(2, '测试文本2', '0x48656C6C6F20576F726C64', 'Hello World'),
(3, '空内容', NULL, 'NULL测试');
COMMIT;
select * from SYSDBA.TEST_BLOB;
使用disql建表正常之后打开trino进行测试
trino>
DESCRIBE dameng.sysdba.test_blob;
select * from dameng.sysdba.test_blob;
重点观察trino中看到的表结构是否有遗漏,以及select查看时是否报错以及查看到的行和列是否齐全,结果如下:
trino> DESCRIBE dameng.sysdba.test_blob;
Column | Type | Extra | Comment
-------------+---------------+-------+---------
id | decimal(10,0) | |
name | varchar(100) | |
blobcontent | varbinary | |
description | varchar(500) | |
(4 rows)
使用trino查看表结构和表内容正常,disql的blob类型在trino内显示为varbinary类型,正常
然后用trino建表
trino>
DROP TABLE IF EXISTS dameng.sysdba.test_blob;
CREATE TABLE dameng.sysdba.test_blob (
id INT,
name VARCHAR(100),
BlobContent VARBINARY,
description VARCHAR(500)
);
DESCRIBE dameng.sysdba.test_blob;
INSERT INTO dameng.sysdba.test_blob (id, name, BlobContent, description) VALUES
(1, '测试图片1', X'89504E470D0A1A0A0000000D49484452', 'PNG文件头'),
(2, '测试文本2', X'48656C6C6F20576F726C64', 'Hello World'),
(3, '空内容', NULL, 'NULL测试');
select * from dameng.sysdba.test_blob;
trino建表、插入、查看均正常,结果如下:
trino> DESCRIBE dameng.sysdba.test_blob;
Column | Type | Extra | Comment
-------------+---------------+-------+---------
id | decimal(10,0) | |
name | varchar(100) | |
blobcontent | varbinary | |
description | varchar(500) | |
(4 rows)
打开disql查看:
SQL>
desc SYSDBA.TEST_BLOB;
select * from SYSDBA.TEST_BLOB;
结果如下:
SQL> desc SYSDBA.TEST_BLOB;
行号 NAME TYPE$ NULLABLE
---------- ----------- ------------ --------
1 ID INTEGER Y
2 NAME VARCHAR(100) Y
3 BLOBCONTENT BLOB Y
4 DESCRIPTION VARCHAR(500) Y
trino的varbinary类型在disql内被存储为blob类型,类型转换正常且内容也正常
CLOB、浮点数(float、real、double)、number、decimal、timestamp等其他类型的测试过程类似,此处略过
| 测试类型 | 在trino中对应 | trino读取已有表 | trino创建和插入表 | 备注 |
|---|---|---|---|---|
| blob | varbinary | 正常 | 正常 | |
| clob | varchar | 正常 | 正常 | |
| float | double | 正常 | 正常 | 达梦中尝试创建float会根据精度转换为real或double |
| real | real | 正常 | 正常 | |
| double | double | 正常 | 正常 | |
| number | number | 正常 | 正常 | |
| decimal | decimal | 正常 | 正常 | |
| timestamp | timestamp | 正常 | 正常 |
如果以上均不存在报错或内容错误,可以将编译的plugin/trino-dameng插件打包,用于分享给其他人用
[root@localhost target]# cd /root [root@localhost ~]# tar -czvf trino-dameng-433-plugin.tar.gz /trino_src/trino-433/plugin/trino-dameng/target/trino-dameng-433/ 【打包过程略】
适配至此结束
trino是一款开源的分布式SQL查询引擎,专为大数据的交互式分析而设计。支持跨多种数据源进行联邦查询(跨源查询)
可以查看项目报错堆栈信息,定位是哪段代码出错了
Caused by: com.google.common.base.VerifyException: Unexpected timestamp precision 19 calculated from timestamp column size 39
at com.google.common.base.Verify.verify(Verify.java:268)
at io.trino.plugin.dameng.DamengClient.getTimestampPrecision(DamengClient.java:442)
at io.trino.plugin.dameng.DamengClient.toColumnMapping(DamengClient.java:303)
在本次适配过程中是DamengClient.java存在问题,使用列大小反推精度时使用的计算公式 精度=列宽度-19-1 存在问题


修改后使用jdbc元数据中的DECIMAL_DIGITS直接得到达梦数据库内部存储的精度大小,更加准确

说明驱动存在问题,需要在trino-dameng中修改对应代码,将达梦数据库中的这些列类型映射到trino能识别的类型上

这里修改了toColumnMapping方法(列映射方法),将CLOB、BLOB映射到trino能支持的类型上
适配trino433的trino-dameng插件代码和编译产物:
文章
阅读量
获赞
