This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-trino.git


The following commit(s) were added to refs/heads/main by this push:
     new a176d9d  Add trino 440 support
a176d9d is described below

commit a176d9d7ba62f78c9717dd47f4060ac92d860fc3
Author: Jingsong <[email protected]>
AuthorDate: Tue May 14 16:00:00 2024 +0800

    Add trino 440 support
---
 paimon-trino-440/pom.xml                           | 211 +++++++++++++++++++++
 paimon-trino-440/src/main/assembly/paimon.xml      |  31 +++
 .../apache/paimon/trino/TestTrino440ITCase.java    |  27 +++
 .../src/test/resources/log4j2-test.properties      |  28 +++
 .../apache/paimon/trino/TrinoConnectorFactory.java |  21 +-
 .../org/apache/paimon/trino/TestTrinoITCase.java   |   3 -
 pom.xml                                            |   4 +-
 7 files changed, 320 insertions(+), 5 deletions(-)

diff --git a/paimon-trino-440/pom.xml b/paimon-trino-440/pom.xml
new file mode 100644
index 0000000..ebd3124
--- /dev/null
+++ b/paimon-trino-440/pom.xml
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<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/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.paimon</groupId>
+        <artifactId>paimon-trino</artifactId>
+        <version>0.8-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>paimon-trino-440</artifactId>
+    <name>Paimon : Trino : 440</name>
+
+    <properties>
+        <target.java.version>17</target.java.version>
+        <jdk.test.version>17</jdk.test.version>
+        <trino.version>440</trino.version>
+        <airlift.version>241</airlift.version>
+        <slice.version>2.2</slice.version>
+        
<maven.toolchains.plugin.version>3.1.0</maven.toolchains.plugin.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.paimon</groupId>
+            <artifactId>paimon-trino-common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-plugin-toolkit</artifactId>
+            <version>${trino.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-spi</artifactId>
+            <version>${trino.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-hdfs</artifactId>
+            <version>${trino.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-hive</artifactId>
+            <version>${trino.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.airlift</groupId>
+            <artifactId>bootstrap</artifactId>
+            <version>${airlift.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.airlift</groupId>
+            <artifactId>configuration</artifactId>
+            <version>${airlift.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.airlift</groupId>
+            <artifactId>slice</artifactId>
+            <version>${slice.version}</version>
+            <scope>provided</scope>
+        </dependency>
+
+        <!-- for testing -->
+
+        <dependency>
+            <groupId>org.apache.paimon</groupId>
+            <artifactId>paimon-trino-common</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-client</artifactId>
+            <version>${trino.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-main</artifactId>
+            <version>${trino.version}</version>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>log4j</groupId>
+                    <artifactId>log4j</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>slf4j-log4j12</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>io.trino</groupId>
+            <artifactId>trino-testing</artifactId>
+            <version>${trino.version}</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <source>${target.java.version}</source>
+                    <target>${target.java.version}</target>
+                    <testSource>${jdk.test.version}</testSource>
+                    <testTarget>${jdk.test.version}</testTarget>
+                    <release>${target.java.version}</release>
+                    <testRelease>${jdk.test.version}</testRelease>
+                    <!-- The semantics of this option are reversed, see 
MCOMPILER-209. -->
+                    
<useIncrementalCompilation>false</useIncrementalCompilation>
+                    <compilerArgs>
+                        <!-- Prevents recompilation due to missing 
package-info.class, see MCOMPILER-205 -->
+                        <arg>-Xpkginfo:always</arg>
+                    </compilerArgs>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.5.5</version>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/main/assembly/paimon.xml</descriptor>
+                    </descriptors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>attached</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>toolchain</id>
+            <activation>
+                <activeByDefault>true</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-toolchains-plugin</artifactId>
+                        <version>${maven.toolchains.plugin.version}</version>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>toolchain</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <toolchains>
+                                <jdk>
+                                    <version>${jdk.test.version}</version>
+                                </jdk>
+                            </toolchains>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/paimon-trino-440/src/main/assembly/paimon.xml 
b/paimon-trino-440/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-440/src/main/assembly/paimon.xml
@@ -0,0 +1,31 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<assembly>
+    <id>plugin</id>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>paimon</outputDirectory>
+            <scope>runtime</scope>
+        </dependencySet>
+    </dependencySets>
+</assembly>
diff --git 
a/paimon-trino-440/src/test/java/org/apache/paimon/trino/TestTrino440ITCase.java
 
b/paimon-trino-440/src/test/java/org/apache/paimon/trino/TestTrino440ITCase.java
new file mode 100644
index 0000000..31bcaa9
--- /dev/null
+++ 
b/paimon-trino-440/src/test/java/org/apache/paimon/trino/TestTrino440ITCase.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.trino;
+
+/** {@link TestTrinoITCase} for Trino 427. */
+public class TestTrino440ITCase extends TestTrinoITCase {
+
+    public TestTrino440ITCase() {
+        super(440);
+    }
+}
diff --git a/paimon-trino-440/src/test/resources/log4j2-test.properties 
b/paimon-trino-440/src/test/resources/log4j2-test.properties
new file mode 100644
index 0000000..1b3980d
--- /dev/null
+++ b/paimon-trino-440/src/test/resources/log4j2-test.properties
@@ -0,0 +1,28 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+# Set root logger level to OFF to not flood build logs
+# set manually to INFO for debugging purposes
+rootLogger.level = OFF
+rootLogger.appenderRef.test.ref = TestLogger
+
+appender.testlogger.name = TestLogger
+appender.testlogger.type = CONSOLE
+appender.testlogger.target = SYSTEM_ERR
+appender.testlogger.layout.type = PatternLayout
+appender.testlogger.layout.pattern = %-4r [%tid %t] %-5p %c %x - %m%n
diff --git 
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
 
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
index 3ccf70f..f6ad6a8 100644
--- 
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
+++ 
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
@@ -39,6 +39,8 @@ import io.trino.spi.connector.ConnectorContext;
 import io.trino.spi.connector.ConnectorFactory;
 import io.trino.spi.type.TypeManager;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Map;
 
 /** Trino {@link ConnectorFactory}. */
@@ -69,7 +71,7 @@ public class TrinoConnectorFactory implements 
ConnectorFactory {
                             new HdfsModule(),
                             new HdfsAuthenticationModule(),
                             // bind the trino file system module
-                            new FileSystemModule(),
+                            newFileSystemModule(catalogName, context),
                             binder -> {
                                 binder.bind(NodeVersion.class)
                                         .toInstance(
@@ -115,4 +117,21 @@ public class TrinoConnectorFactory implements 
ConnectorFactory {
         @Override
         public void configure(Binder binder) {}
     }
+
+    private static FileSystemModule newFileSystemModule(
+            String catalogName, ConnectorContext context) {
+        Constructor<?> constructor = 
FileSystemModule.class.getConstructors()[0];
+        try {
+            if (constructor.getParameterCount() == 0) {
+                return (FileSystemModule) constructor.newInstance();
+            } else {
+                // for trino 440
+                return (FileSystemModule)
+                        constructor.newInstance(
+                                catalogName, context.getNodeManager(), 
context.getOpenTelemetry());
+            }
+        } catch (InstantiationException | InvocationTargetException | 
IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
 }
diff --git 
a/paimon-trino-common/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java
 
b/paimon-trino-common/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java
index 99f54d4..59378a6 100644
--- 
a/paimon-trino-common/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java
+++ 
b/paimon-trino-common/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java
@@ -778,9 +778,6 @@ public abstract class TestTrinoITCase extends 
AbstractTestQueryFramework {
 
     @Test
     public void testTimeTravel() {
-        if (trinoVersion < 368) {
-            return;
-        }
         assertThat(sql("SELECT * FROM paimon.default.t2 FOR VERSION AS OF 1"))
                 .isEqualTo("[[1, 2, 1, 1], [3, 4, 2, 2]]");
         assertThat(sql("SELECT * FROM paimon.default.t2 FOR VERSION AS OF 2"))
diff --git a/pom.xml b/pom.xml
index 4bd3084..ca8202d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,7 @@ under the License.
     <modules>
         <module>paimon-trino-420</module>
         <module>paimon-trino-427</module>
+        <module>paimon-trino-440</module>
         <module>paimon-trino-common</module>
     </modules>
 
@@ -58,6 +59,7 @@ under the License.
     </scm>
 
     <properties>
+        <paimon.version>0.8.0</paimon.version>
         <target.java.version>11</target.java.version>
         <junit5.version>5.8.1</junit5.version>
         <slf4j.version>2.0.7</slf4j.version>
@@ -93,7 +95,7 @@ under the License.
         <dependency>
             <groupId>org.apache.paimon</groupId>
             <artifactId>paimon-bundle</artifactId>
-            <version>${project.version}</version>
+            <version>${paimon.version}</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.slf4j</groupId>

Reply via email to