Trino is fully customizable with custom plugins. Those plugins can be developed in Java and deployed to Trino clusters. One of the aspects of success in development Trino plugins depends on your development environment. If you are able to mimic the Trino team environment, you might encounter less issues and problems during development and debug stages. The article shows some mandatory or preferable steps before starting your plugin.
The sample is created in CentOS 7 for Trino 393.
1. Java 17 is supported and the minimum version is 17.0.3.
java --version
2. Maven is installed. Minimal Maven version is 3.6.0 for Java 17 as per Maven documentation.
mvn --version
3. Generate a new plugin project in Maven
mvn archetype:generate -DgroupId=com.sample.plugin -DartifactId=sample-plugin -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
The command creates a new subfolder with sample-plugin
name. The subfolder includes pom.xml
file and children folders as per groupId=com.sample.plugin
parameter.
4. Go to the new folder
cd sample-plugin
5. Modify pom file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sample.plugin</groupId>
<artifactId>sample-plugin</artifactId>
<version>393</version>
<description>Trino - Sample Plugin</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<!-- Trino mandatory dependency -->
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add your dependencies -->
<!-- Quick start archetype test if needed-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6. Unpack the maven-wrapper distribution files to the current project source tree
mvn wrapper:wrapper
The Maven Wrapper makes life easier to ensure that your Maven build has everything necessary to run your Maven build. It is added .mvn
subfolder, and mvnw
and mvnw.cmd
files.
7. Create the package
./mvnw clean package dependency:copy-dependencies
Instead of mvn
command, the Maven wrapper is used.
8. Test
java -cp target/sample-plugin-393.jar com.sample.plugin.App
This test is not plugin test. It's just test to validate the development environment.
9. Clean up the project from the sample
- Delete sample code
- Delete tests
- Remove junit dependency from pom file
Comments
comments powered by Disqus