Trino UDF 开发
Trino UDF 开发
UDF 开发
UDF 打包
使用 maven 管理依赖,使用 maven-shade-plugin 打 fat 包。在 pom.xml 增加如下 build 标签
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>io.trino:trino-spi</exclude>
<exclude>io.trino:trino-array</exclude>
<exclude>joda-time:joda-time</exclude>
<exclude>io.airlift:log</exclude>
</excludes>
</artifactSet>
<shadedArtifactAttached>true</shadedArtifactAttached>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/DEPENDENCIES</exclude>
<exclude>META-INF/LICENSE*</exclude>
<exclude>META-INF/NOTICE*</exclude>
<exclude>META-INF/MANIFEST*</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<!-- Tweak the compiler to use more memory and use UTF-8 for the source code. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.source}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<!-- Resource plugins should always use UTF-8 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
由于 Trino 依赖 Java 11,所以 UDF 同样需要 Java 11 开发和编译。
# 使用 sdkman 环境工具切换到 java 11 环境 (开发环境基础工具,自行搜索安装及用法)
sdk use java 11.0.14.fx-zulu
mvn clean package