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/incubator-paimon-trino.git
The following commit(s) were added to refs/heads/main by this push:
new 983a60b Use injection (#50)
983a60b is described below
commit 983a60b9f50ed89b3625d4d3284de1a258064b51
Author: shidayang <[email protected]>
AuthorDate: Wed Dec 20 21:22:43 2023 +0800
Use injection (#50)
---
paimon-trino-358/pom.xml | 69 +-------------
paimon-trino-358/src/main/assembly/paimon.xml | 31 ++++++
.../org/apache/paimon/trino/TrinoMetadata.java | 6 +-
paimon-trino-368/pom.xml | 68 +-------------
paimon-trino-368/src/main/assembly/paimon.xml | 31 ++++++
.../org/apache/paimon/trino/TrinoMetadata.java | 16 +---
paimon-trino-369/pom.xml | 68 +-------------
paimon-trino-369/src/main/assembly/paimon.xml | 31 ++++++
.../org/apache/paimon/trino/TrinoMetadata.java | 16 +---
paimon-trino-370/pom.xml | 68 +-------------
paimon-trino-370/src/main/assembly/paimon.xml | 31 ++++++
.../org/apache/paimon/trino/TrinoMetadata.java | 16 +---
paimon-trino-388/pom.xml | 69 +-------------
paimon-trino-388/src/main/assembly/paimon.xml | 31 ++++++
paimon-trino-393/pom.xml | 69 +-------------
paimon-trino-393/src/main/assembly/paimon.xml | 31 ++++++
paimon-trino-422/pom.xml | 69 +++-----------
paimon-trino-422/src/main/assembly/paimon.xml | 31 ++++++
.../org/apache/paimon/trino/TrinoConnector.java | 11 ++-
.../apache/paimon/trino/TrinoConnectorFactory.java | 54 +++++++++++
.../apache/paimon/trino/TrinoMetadataFactory.java | 62 ++++++++++++
paimon-trino-common/pom.xml | 58 +++++-------
.../org/apache/paimon/trino/HiveHdfsModule.java | 52 +++++++++++
.../org/apache/paimon/trino/TrinoConnector.java | 11 ++-
.../apache/paimon/trino/TrinoConnectorBase.java | 10 +-
.../paimon/trino/TrinoConnectorFactoryBase.java | 104 ++++++++++-----------
.../org/apache/paimon/trino/TrinoMetadata.java | 16 +---
.../org/apache/paimon/trino/TrinoMetadataBase.java | 15 +--
.../apache/paimon/trino/TrinoMetadataFactory.java | 62 ++++++++++++
.../java/org/apache/paimon/trino/TrinoModule.java | 25 +++--
pom.xml | 89 ++++--------------
31 files changed, 611 insertions(+), 709 deletions(-)
diff --git a/paimon-trino-358/pom.xml b/paimon-trino-358/pom.xml
index 4e0a706..2dafa57 100644
--- a/paimon-trino-358/pom.xml
+++ b/paimon-trino-358/pom.xml
@@ -33,9 +33,6 @@ under the License.
<properties>
<trino.version>358</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
</properties>
<dependencies>
@@ -59,21 +56,7 @@ under the License.
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.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>
@@ -112,63 +95,13 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-358/src/main/assembly/paimon.xml
b/paimon-trino-358/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-358/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-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
index f598246..3d5e04c 100644
--- a/paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++ b/paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
@@ -18,15 +18,15 @@
package org.apache.paimon.trino;
-import org.apache.paimon.options.Options;
+import org.apache.paimon.catalog.Catalog;
import io.trino.spi.connector.ConnectorMetadata;
/** Trino {@link ConnectorMetadata}. */
public class TrinoMetadata extends TrinoMetadataBase {
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
+ public TrinoMetadata(Catalog catalog) {
+ super(catalog);
}
@Override
diff --git a/paimon-trino-368/pom.xml b/paimon-trino-368/pom.xml
index 3285542..dc7d4db 100644
--- a/paimon-trino-368/pom.xml
+++ b/paimon-trino-368/pom.xml
@@ -33,9 +33,6 @@ under the License.
<properties>
<trino.version>368</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
</properties>
<dependencies>
@@ -59,19 +56,6 @@ under the License.
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>slice</artifactId>
- <version>${slice.version}</version>
- <scope>provided</scope>
- </dependency>
-
<!-- for testing -->
<dependency>
@@ -112,63 +96,13 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-368/src/main/assembly/paimon.xml
b/paimon-trino-368/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-368/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-368/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-368/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
index 1e31625..31fa993 100644
--- a/paimon-trino-368/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++ b/paimon-trino-368/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
@@ -20,12 +20,8 @@ package org.apache.paimon.trino;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.CatalogContext;
-import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.options.Options;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.security.SecurityContext;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorMetadata;
@@ -52,16 +48,8 @@ import static java.util.stream.Collectors.toMap;
/** Trino {@link ConnectorMetadata}. */
public class TrinoMetadata extends TrinoMetadataBase {
- private final Catalog catalog;
-
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
- try {
- SecurityContext.install(catalogOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- this.catalog =
CatalogFactory.createCatalog(CatalogContext.create(catalogOptions));
+ public TrinoMetadata(Catalog catalog) {
+ super(catalog);
}
@Override
diff --git a/paimon-trino-369/pom.xml b/paimon-trino-369/pom.xml
index e28e7e5..e89bb03 100644
--- a/paimon-trino-369/pom.xml
+++ b/paimon-trino-369/pom.xml
@@ -33,9 +33,6 @@ under the License.
<properties>
<trino.version>369</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
</properties>
<dependencies>
@@ -59,19 +56,6 @@ under the License.
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>slice</artifactId>
- <version>${slice.version}</version>
- <scope>provided</scope>
- </dependency>
-
<!-- for testing -->
<dependency>
@@ -112,63 +96,13 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-369/src/main/assembly/paimon.xml
b/paimon-trino-369/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-369/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-369/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-369/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
index 1caf53f..b03ae50 100644
--- a/paimon-trino-369/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++ b/paimon-trino-369/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
@@ -20,12 +20,8 @@ package org.apache.paimon.trino;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.CatalogContext;
-import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.options.Options;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.security.SecurityContext;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorMetadata;
@@ -52,16 +48,8 @@ import static java.util.stream.Collectors.toMap;
/** Trino {@link ConnectorMetadata}. */
public class TrinoMetadata extends TrinoMetadataBase {
- private final Catalog catalog;
-
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
- try {
- SecurityContext.install(catalogOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- this.catalog =
CatalogFactory.createCatalog(CatalogContext.create(catalogOptions));
+ public TrinoMetadata(Catalog catalog) {
+ super(catalog);
}
@Override
diff --git a/paimon-trino-370/pom.xml b/paimon-trino-370/pom.xml
index b462ff5..e0d6788 100644
--- a/paimon-trino-370/pom.xml
+++ b/paimon-trino-370/pom.xml
@@ -33,9 +33,6 @@ under the License.
<properties>
<trino.version>370</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
</properties>
<dependencies>
@@ -59,19 +56,6 @@ under the License.
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>slice</artifactId>
- <version>${slice.version}</version>
- <scope>provided</scope>
- </dependency>
-
<!-- for testing -->
<dependency>
@@ -112,63 +96,13 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-370/src/main/assembly/paimon.xml
b/paimon-trino-370/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-370/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-370/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-370/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
index 9a33668..9875ae0 100644
--- a/paimon-trino-370/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++ b/paimon-trino-370/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
@@ -20,12 +20,8 @@ package org.apache.paimon.trino;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.CatalogContext;
-import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.options.Options;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.security.SecurityContext;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorMetadata;
@@ -52,16 +48,8 @@ import static java.util.stream.Collectors.toMap;
/** Trino {@link ConnectorMetadata}. */
public class TrinoMetadata extends TrinoMetadataBase {
- private final Catalog catalog;
-
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
- try {
- SecurityContext.install(catalogOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- this.catalog =
CatalogFactory.createCatalog(CatalogContext.create(catalogOptions));
+ public TrinoMetadata(Catalog catalog) {
+ super(catalog);
}
@Override
diff --git a/paimon-trino-388/pom.xml b/paimon-trino-388/pom.xml
index 249d791..61bd557 100644
--- a/paimon-trino-388/pom.xml
+++ b/paimon-trino-388/pom.xml
@@ -33,9 +33,6 @@ under the License.
<properties>
<trino.version>388</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
</properties>
<dependencies>
@@ -56,20 +53,6 @@ under the License.
<groupId>io.trino</groupId>
<artifactId>trino-spi</artifactId>
<version>${trino.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>slice</artifactId>
- <version>${slice.version}</version>
- <scope>provided</scope>
</dependency>
<!-- for testing -->
@@ -112,63 +95,13 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-388/src/main/assembly/paimon.xml
b/paimon-trino-388/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-388/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-393/pom.xml b/paimon-trino-393/pom.xml
index 0a14b82..3aed07e 100644
--- a/paimon-trino-393/pom.xml
+++ b/paimon-trino-393/pom.xml
@@ -35,9 +35,6 @@ under the License.
<target.java.version>17</target.java.version>
<jdk.test.version>17</jdk.test.version>
<trino.version>393</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
- <slice.version>0.42</slice.version>
<maven.toolchains.plugin.version>3.1.0</maven.toolchains.plugin.version>
</properties>
@@ -61,20 +58,6 @@ under the License.
<version>${trino.version}</version>
<scope>provided</scope>
</dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>configuration</artifactId>
- <version>${configuration.version}</version>
- </dependency>
-
- <dependency>
- <groupId>io.airlift</groupId>
- <artifactId>slice</artifactId>
- <version>${slice.version}</version>
- <scope>provided</scope>
- </dependency>
-
<!-- for testing -->
<dependency>
@@ -115,40 +98,6 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
@@ -175,23 +124,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-393/src/main/assembly/paimon.xml
b/paimon-trino-393/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-393/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-422/pom.xml b/paimon-trino-422/pom.xml
index 356a927..922b287 100644
--- a/paimon-trino-422/pom.xml
+++ b/paimon-trino-422/pom.xml
@@ -35,8 +35,7 @@ under the License.
<target.java.version>17</target.java.version>
<jdk.test.version>17</jdk.test.version>
<trino.version>422</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>235</configuration.version>
+ <airlift.version>235</airlift.version>
<slice.version>0.45</slice.version>
<maven.toolchains.plugin.version>3.1.0</maven.toolchains.plugin.version>
</properties>
@@ -62,10 +61,22 @@ under the License.
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>io.trino</groupId>
+ <artifactId>trino-hdfs</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>${configuration.version}</version>
+ <version>${airlift.version}</version>
</dependency>
<dependency>
@@ -115,40 +126,6 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
@@ -175,23 +152,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <artifactSet>
- <includes combine.children="append">
-
<include>org.apache.paimon:paimon-trino-common</include>
- </includes>
- </artifactSet>
- </configuration>
- </execution>
- </executions>
+ <artifactId>maven-assembly-plugin</artifactId>
</plugin>
</plugins>
</build>
diff --git a/paimon-trino-422/src/main/assembly/paimon.xml
b/paimon-trino-422/src/main/assembly/paimon.xml
new file mode 100644
index 0000000..ba1bd63
--- /dev/null
+++ b/paimon-trino-422/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-422/src/main/java/org/apache/paimon/trino/TrinoConnector.java
b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnector.java
index 0f35f46..beff06a 100644
--- a/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnector.java
+++ b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnector.java
@@ -30,8 +30,15 @@ public class TrinoConnector extends TrinoConnectorBase {
public TrinoConnector(
TrinoMetadataBase trinoMetadata,
TrinoSplitManagerBase trinoSplitManager,
- TrinoPageSourceProvider trinoPageSourceProvider) {
- super(trinoMetadata, trinoSplitManager, trinoPageSourceProvider);
+ TrinoPageSourceProvider trinoPageSourceProvider,
+ TrinoTableOptions trinoTableOptions,
+ TrinoSessionProperties trinoSessionProperties) {
+ super(
+ trinoMetadata,
+ trinoSplitManager,
+ trinoPageSourceProvider,
+ trinoTableOptions,
+ trinoSessionProperties);
}
@Override
diff --git
a/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
new file mode 100644
index 0000000..270c031
--- /dev/null
+++
b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoConnectorFactory.java
@@ -0,0 +1,54 @@
+/*
+ * 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;
+
+import com.google.inject.Module;
+import io.airlift.json.JsonModule;
+import io.opentelemetry.api.OpenTelemetry;
+import io.trino.hdfs.HdfsModule;
+import io.trino.hdfs.authentication.HdfsAuthenticationModule;
+import io.trino.plugin.hive.NodeVersion;
+import io.trino.spi.connector.ConnectorContext;
+import io.trino.spi.connector.ConnectorFactory;
+import io.trino.spi.type.TypeManager;
+
+import java.util.Map;
+
+/** Trino {@link ConnectorFactory}. */
+public class TrinoConnectorFactory extends TrinoConnectorFactoryBase {
+
+ @Override
+ protected Module[] modules(
+ String catalogName, Map<String, String> config, ConnectorContext
context) {
+ return new Module[] {
+ new JsonModule(),
+ new TrinoModule(config),
+ new HdfsModule(),
+ new HdfsAuthenticationModule(),
+ binder -> {
+ binder.bind(NodeVersion.class)
+ .toInstance(
+ new NodeVersion(
+
context.getNodeManager().getCurrentNode().getVersion()));
+
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
+
binder.bind(OpenTelemetry.class).toInstance(context.getOpenTelemetry());
+ }
+ };
+ }
+}
diff --git
a/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
new file mode 100644
index 0000000..4dc6772
--- /dev/null
+++
b/paimon-trino-422/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.security.SecurityContext;
+
+import com.google.inject.Inject;
+import io.trino.hdfs.ConfigurationUtils;
+import io.trino.hdfs.HdfsConfig;
+import io.trino.hdfs.HdfsConfigurationInitializer;
+import org.apache.hadoop.conf.Configuration;
+
+/** A factory to create {@link TrinoMetadata}. */
+public class TrinoMetadataFactory {
+
+ private final Catalog catalog;
+
+ @Inject
+ public TrinoMetadataFactory(
+ Options options,
+ HdfsConfigurationInitializer hdfsConfigurationInitializer,
+ HdfsConfig hdfsConfig) {
+ CatalogContext catalogContext;
+ if (hdfsConfig.getResourceConfigFiles().isEmpty()) {
+ catalogContext = CatalogContext.create(options);
+ } else {
+ Configuration configuration =
ConfigurationUtils.getInitialConfiguration();
+
hdfsConfigurationInitializer.initializeConfiguration(configuration);
+ catalogContext = CatalogContext.create(options, configuration);
+ }
+ try {
+ SecurityContext.install(catalogContext);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.catalog = CatalogFactory.createCatalog(catalogContext);
+ }
+
+ public TrinoMetadata create() {
+ return new TrinoMetadata(catalog);
+ }
+}
diff --git a/paimon-trino-common/pom.xml b/paimon-trino-common/pom.xml
index 65c1cc3..febd3c8 100644
--- a/paimon-trino-common/pom.xml
+++ b/paimon-trino-common/pom.xml
@@ -35,12 +35,18 @@ under the License.
<properties>
<trino.version>388</trino.version>
- <hadoop.version>2.8.5</hadoop.version>
- <configuration.version>216</configuration.version>
<slice.version>0.42</slice.version>
+ <airlift.version>216</airlift.version>
+ <hadoop.apache.version>3.2.0-18</hadoop.apache.version>
</properties>
<dependencies>
+ <dependency>
+ <groupId>io.trino.hadoop</groupId>
+ <artifactId>hadoop-apache</artifactId>
+ <version>${hadoop.apache.version}</version>
+ </dependency>
+
<dependency>
<groupId>io.trino</groupId>
<artifactId>trino-plugin-toolkit</artifactId>
@@ -55,10 +61,22 @@ under the License.
<scope>provided</scope>
</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>${configuration.version}</version>
+ <version>${airlift.version}</version>
</dependency>
<dependency>
@@ -99,40 +117,6 @@ under the License.
<version>${trino.version}</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- <version>${hadoop.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>org.apache.hadoop</groupId>
- <artifactId>hadoop-client</artifactId>
- <version>${hadoop.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>
</dependencies>
<build>
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/HiveHdfsModule.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/HiveHdfsModule.java
new file mode 100644
index 0000000..18de705
--- /dev/null
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/HiveHdfsModule.java
@@ -0,0 +1,52 @@
+/*
+ * 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;
+
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.google.inject.Scopes;
+import io.trino.plugin.hive.ConfigurationInitializer;
+import io.trino.plugin.hive.DynamicConfigurationProvider;
+import io.trino.plugin.hive.HdfsConfig;
+import io.trino.plugin.hive.HdfsConfiguration;
+import io.trino.plugin.hive.HdfsConfigurationInitializer;
+import io.trino.plugin.hive.HdfsEnvironment;
+import io.trino.plugin.hive.HiveHdfsConfiguration;
+
+import static com.google.inject.multibindings.Multibinder.newSetBinder;
+import static io.airlift.configuration.ConfigBinder.configBinder;
+
+/**
+ * Copied from {@link io.trino.plugin.hive.HiveHdfsModule}. We removed the
{@link
+ * io.trino.plugin.hive.NamenodeStats}, as Trino relies on different versions
of jol-core across
+ * versions, leading to potential conflicts with the dependency on jol-core by
NamenodeStats.
+ */
+public class HiveHdfsModule implements Module {
+ @Override
+ public void configure(Binder binder) {
+ configBinder(binder).bindConfig(HdfsConfig.class);
+
+
binder.bind(HdfsConfiguration.class).to(HiveHdfsConfiguration.class).in(Scopes.SINGLETON);
+ binder.bind(HdfsEnvironment.class).in(Scopes.SINGLETON);
+
+ binder.bind(HdfsConfigurationInitializer.class).in(Scopes.SINGLETON);
+ newSetBinder(binder, ConfigurationInitializer.class);
+ newSetBinder(binder, DynamicConfigurationProvider.class);
+ }
+}
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnector.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnector.java
index eeda512..beaf55b 100644
---
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnector.java
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnector.java
@@ -28,8 +28,15 @@ public class TrinoConnector extends TrinoConnectorBase {
public TrinoConnector(
TrinoMetadataBase trinoMetadata,
TrinoSplitManagerBase trinoSplitManager,
- TrinoPageSourceProvider trinoPageSourceProvider) {
- super(trinoMetadata, trinoSplitManager, trinoPageSourceProvider);
+ TrinoPageSourceProvider trinoPageSourceProvider,
+ TrinoTableOptions trinoTableOptions,
+ TrinoSessionProperties trinoSessionProperties) {
+ super(
+ trinoMetadata,
+ trinoSplitManager,
+ trinoPageSourceProvider,
+ trinoTableOptions,
+ trinoSessionProperties);
}
@Override
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorBase.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorBase.java
index 7572e95..8f3e0b2 100644
---
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorBase.java
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorBase.java
@@ -28,7 +28,6 @@ import java.util.List;
import static io.trino.spi.transaction.IsolationLevel.READ_COMMITTED;
import static io.trino.spi.transaction.IsolationLevel.checkConnectorSupports;
import static java.util.Objects.requireNonNull;
-import static
org.apache.paimon.shade.guava30.com.google.common.collect.ImmutableList.toImmutableList;
/** Trino {@link Connector}. */
public abstract class TrinoConnectorBase implements Connector {
@@ -41,14 +40,15 @@ public abstract class TrinoConnectorBase implements
Connector {
public TrinoConnectorBase(
TrinoMetadataBase trinoMetadata,
TrinoSplitManagerBase trinoSplitManager,
- TrinoPageSourceProvider trinoPageSourceProvider) {
+ TrinoPageSourceProvider trinoPageSourceProvider,
+ TrinoTableOptions trinoTableOptions,
+ TrinoSessionProperties trinoSessionProperties) {
this.trinoMetadata = requireNonNull(trinoMetadata, "jmxMetadata is
null");
this.trinoSplitManager = requireNonNull(trinoSplitManager,
"jmxSplitManager is null");
this.trinoPageSourceProvider =
requireNonNull(trinoPageSourceProvider, "jmxRecordSetProvider
is null");
- tableProperties =
- new
TrinoTableOptions().getTableProperties().stream().collect(toImmutableList());
- sessionProperties = new
TrinoSessionProperties().getSessionProperties();
+ this.tableProperties = trinoTableOptions.getTableProperties();
+ sessionProperties = trinoSessionProperties.getSessionProperties();
}
protected ConnectorTransactionHandle beginTransactionBase(
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactoryBase.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactoryBase.java
index 3808d28..5338b8e 100644
---
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactoryBase.java
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoConnectorFactoryBase.java
@@ -18,34 +18,24 @@
package org.apache.paimon.trino;
-import org.apache.paimon.options.Options;
-import org.apache.paimon.utils.StringUtils;
-
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import io.airlift.bootstrap.Bootstrap;
+import io.airlift.json.JsonModule;
+import io.trino.plugin.hive.HiveHdfsModule;
+import io.trino.plugin.hive.NodeVersion;
+import io.trino.plugin.hive.authentication.HdfsAuthenticationModule;
+import io.trino.spi.classloader.ThreadContextClassLoader;
import io.trino.spi.connector.Connector;
import io.trino.spi.connector.ConnectorContext;
import io.trino.spi.connector.ConnectorFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import javax.xml.parsers.DocumentBuilderFactory;
+import io.trino.spi.type.TypeManager;
-import java.io.File;
-import java.util.HashMap;
import java.util.Map;
/** Trino {@link ConnectorFactory}. */
public abstract class TrinoConnectorFactoryBase implements ConnectorFactory {
- private static final Logger LOG =
LoggerFactory.getLogger(TrinoConnectorFactoryBase.class);
-
- // see
https://trino.io/docs/current/connector/hive.html#hive-general-configuration-properties
- private static final String HADOOP_CONF_FILES_KEY =
"hive.config.resources";
- // see org.apache.paimon.utils.HadoopUtils
- private static final String HADOOP_CONF_PREFIX = "hadoop.";
-
@Override
public String getName() {
return "paimon";
@@ -54,48 +44,48 @@ public abstract class TrinoConnectorFactoryBase implements
ConnectorFactory {
@Override
public Connector create(
String catalogName, Map<String, String> config, ConnectorContext
context) {
- config = new HashMap<>(config);
- if (config.containsKey(HADOOP_CONF_FILES_KEY)) {
- for (String hadoopXml :
config.get(HADOOP_CONF_FILES_KEY).split(",")) {
- try {
- readHadoopXml(hadoopXml, config);
- } catch (Exception e) {
- LOG.warn(
- "Failed to read hadoop xml file " + hadoopXml + ",
skipping this file.",
- e);
- }
- }
- }
- return new TrinoConnector(
- new TrinoMetadata(Options.fromMap(config)),
- new TrinoSplitManager(),
- new TrinoPageSourceProvider());
- }
+ try (ThreadContextClassLoader ignored =
+ new
ThreadContextClassLoader(TrinoConnectorFactoryBase.class.getClassLoader())) {
+ Bootstrap app = new Bootstrap(modules(catalogName, config,
context));
+
+ Injector injector =
+ app.doNotInitializeLogging()
+ .setRequiredConfigurationProperties(Map.of())
+ .setOptionalConfigurationProperties(config)
+ .initialize();
+
+ TrinoMetadata trinoMetadata =
injector.getInstance(TrinoMetadataFactory.class).create();
+ TrinoSplitManager trinoSplitManager =
injector.getInstance(TrinoSplitManager.class);
+ TrinoPageSourceProvider trinoPageSourceProvider =
+ injector.getInstance(TrinoPageSourceProvider.class);
+ TrinoSessionProperties trinoSessionProperties =
+ injector.getInstance(TrinoSessionProperties.class);
+ TrinoTableOptions trinoTableOptions =
injector.getInstance(TrinoTableOptions.class);
- private void readHadoopXml(String path, Map<String, String> config) throws
Exception {
- path = path.trim();
- if (path.isEmpty()) {
- return;
+ return new TrinoConnector(
+ trinoMetadata,
+ trinoSplitManager,
+ trinoPageSourceProvider,
+ trinoTableOptions,
+ trinoSessionProperties);
}
+ }
- File xmlFile = new File(path);
- NodeList propertyNodes =
- DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
- .parse(xmlFile)
- .getElementsByTagName("property");
- for (int i = 0; i < propertyNodes.getLength(); i++) {
- Node propertyNode = propertyNodes.item(i);
- if (propertyNode.getNodeType() == 1) {
- Element propertyElement = (Element) propertyNode;
- String key =
propertyElement.getElementsByTagName("name").item(0).getTextContent();
- String value =
-
propertyElement.getElementsByTagName("value").item(0).getTextContent();
- if (!StringUtils.isNullOrWhitespaceOnly(value)) {
- config.putIfAbsent(HADOOP_CONF_PREFIX + key, value);
- }
+ protected Module[] modules(
+ String catalogName, Map<String, String> config, ConnectorContext
context) {
+ return new Module[] {
+ new JsonModule(),
+ new TrinoModule(config),
+ new HiveHdfsModule(),
+ new HdfsAuthenticationModule(),
+ binder -> {
+ binder.bind(NodeVersion.class)
+ .toInstance(
+ new NodeVersion(
+
context.getNodeManager().getCurrentNode().getVersion()));
+
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
}
- }
+ };
}
}
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
index 8bf7d90..8f96681 100644
---
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
@@ -20,12 +20,8 @@ package org.apache.paimon.trino;
import org.apache.paimon.CoreOptions;
import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.CatalogContext;
-import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.options.Options;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.security.SecurityContext;
import io.trino.spi.TrinoException;
import io.trino.spi.connector.ConnectorMetadata;
@@ -51,16 +47,8 @@ import static java.util.stream.Collectors.toMap;
/** Trino {@link ConnectorMetadata}. */
public class TrinoMetadata extends TrinoMetadataBase {
- private final Catalog catalog;
-
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
- try {
- SecurityContext.install(catalogOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- this.catalog =
CatalogFactory.createCatalog(CatalogContext.create(catalogOptions));
+ public TrinoMetadata(Catalog catalog) {
+ super(catalog);
}
@Override
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataBase.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataBase.java
index e4482a8..3899642 100644
---
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataBase.java
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataBase.java
@@ -19,13 +19,9 @@
package org.apache.paimon.trino;
import org.apache.paimon.catalog.Catalog;
-import org.apache.paimon.catalog.CatalogContext;
-import org.apache.paimon.catalog.CatalogFactory;
import org.apache.paimon.catalog.Identifier;
-import org.apache.paimon.options.Options;
import org.apache.paimon.schema.Schema;
import org.apache.paimon.schema.SchemaChange;
-import org.apache.paimon.security.SecurityContext;
import org.apache.paimon.table.Table;
import org.apache.paimon.utils.InstantiationUtil;
import org.apache.paimon.utils.StringUtils;
@@ -73,15 +69,10 @@ import static
org.apache.paimon.utils.Preconditions.checkArgument;
/** Trino {@link ConnectorMetadata}. */
public abstract class TrinoMetadataBase implements ConnectorMetadata {
- private final Catalog catalog;
+ protected final Catalog catalog;
- public TrinoMetadataBase(Options catalogOptions) {
- try {
- SecurityContext.install(catalogOptions);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- this.catalog =
CatalogFactory.createCatalog(CatalogContext.create(catalogOptions));
+ public TrinoMetadataBase(Catalog catalog) {
+ this.catalog = catalog;
}
@Override
diff --git
a/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
new file mode 100644
index 0000000..4b03327
--- /dev/null
+++
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoMetadataFactory.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.CatalogContext;
+import org.apache.paimon.catalog.CatalogFactory;
+import org.apache.paimon.options.Options;
+import org.apache.paimon.security.SecurityContext;
+
+import com.google.inject.Inject;
+import io.trino.plugin.hive.HdfsConfig;
+import io.trino.plugin.hive.HdfsConfigurationInitializer;
+import io.trino.plugin.hive.util.ConfigurationUtils;
+import org.apache.hadoop.conf.Configuration;
+
+/** A factory to create {@link TrinoMetadata}. */
+public class TrinoMetadataFactory {
+
+ private final Catalog catalog;
+
+ @Inject
+ public TrinoMetadataFactory(
+ Options options,
+ HdfsConfigurationInitializer hdfsConfigurationInitializer,
+ HdfsConfig hdfsConfig) {
+ CatalogContext catalogContext;
+ if (hdfsConfig.getResourceConfigFiles().isEmpty()) {
+ catalogContext = CatalogContext.create(options);
+ } else {
+ Configuration configuration =
ConfigurationUtils.getInitialConfiguration();
+
hdfsConfigurationInitializer.initializeConfiguration(configuration);
+ catalogContext = CatalogContext.create(options, configuration);
+ }
+ try {
+ SecurityContext.install(catalogContext);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.catalog = CatalogFactory.createCatalog(catalogContext);
+ }
+
+ public TrinoMetadata create() {
+ return new TrinoMetadata(catalog);
+ }
+}
diff --git
a/paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoModule.java
similarity index 54%
copy from
paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
copy to
paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoModule.java
index f598246..da22ed6 100644
--- a/paimon-trino-358/src/main/java/org/apache/paimon/trino/TrinoMetadata.java
+++ b/paimon-trino-common/src/main/java/org/apache/paimon/trino/TrinoModule.java
@@ -20,17 +20,28 @@ package org.apache.paimon.trino;
import org.apache.paimon.options.Options;
-import io.trino.spi.connector.ConnectorMetadata;
+import com.google.inject.Binder;
+import com.google.inject.Module;
-/** Trino {@link ConnectorMetadata}. */
-public class TrinoMetadata extends TrinoMetadataBase {
+import java.util.Map;
- public TrinoMetadata(Options catalogOptions) {
- super(catalogOptions);
+import static com.google.inject.Scopes.SINGLETON;
+
+/** Module for binding instance. */
+public class TrinoModule implements Module {
+ private Map<String, String> config;
+
+ public TrinoModule(Map<String, String> config) {
+ this.config = config;
}
@Override
- public boolean usesLegacyTableLayouts() {
- return false;
+ public void configure(Binder binder) {
+ binder.bind(Options.class).toInstance(new Options(config));
+ binder.bind(TrinoMetadataFactory.class).in(SINGLETON);
+ binder.bind(TrinoSplitManager.class).in(SINGLETON);
+ binder.bind(TrinoPageSourceProvider.class).in(SINGLETON);
+ binder.bind(TrinoSessionProperties.class).in(SINGLETON);
+ binder.bind(TrinoTableOptions.class).in(SINGLETON);
}
}
diff --git a/pom.xml b/pom.xml
index 4511c19..9cac8ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -366,75 +366,6 @@ under the License.
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <executions>
- <execution>
- <id>shade-paimon</id>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <shadeTestJar>true</shadeTestJar>
-
<shadedArtifactAttached>false</shadedArtifactAttached>
-
<createDependencyReducedPom>true</createDependencyReducedPom>
- <!-- Filters MUST be appended; merging filters
does not work properly, see MSHADE-305 -->
- <filters combine.children="append">
- <!-- Globally exclude log4j.properties from
our JAR files. -->
- <filter>
- <artifact>*</artifact>
- <excludes>
- <exclude>log4j.properties</exclude>
- <exclude>log4j2.properties</exclude>
-
<exclude>log4j-test.properties</exclude>
-
<exclude>log4j2-test.properties</exclude>
- </excludes>
- </filter>
- <!-- drop entries into META-INF and NOTICE
files for the dummy artifact -->
- <filter>
-
<artifact>org.apache.flink:force-shading</artifact>
- <excludes>
- <exclude>**</exclude>
- </excludes>
- </filter>
- <!-- io.netty:netty brings its own LICENSE.txt
which we don't need -->
- <filter>
- <artifact>io.netty:netty</artifact>
- <excludes>
- <exclude>META-INF/LICENSE.txt</exclude>
- </excludes>
- </filter>
- </filters>
- <artifactSet>
- <includes>
- <!-- Unfortunately, the next line is
necessary for now to force the execution
- of the Shade plugin upon all sub modules.
This will generate effective poms,
- i.e. poms which do not contain properties
which are derived from this root pom.
- In particular, the Scala version
properties are defined in the root pom and without
- shading, the root pom would have to be
Scala suffixed and thereby all other modules.
- -->
-
<include>org.apache.flink:force-shading</include>
- </includes>
- </artifactSet>
- <transformers combine.children="append">
- <!-- The service transformer is needed to
merge META-INF/services files -->
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
- <!-- The ApacheNoticeResourceTransformer
collects and aggregates NOTICE files -->
- <transformer
-
implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
- <projectName>Apache Paimon
(incubating)</projectName>
-
<inceptionYear>${project.inceptionYear}</inceptionYear>
- <encoding>UTF-8</encoding>
- </transformer>
- </transformers>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -601,7 +532,27 @@ under the License.
</execution>
</executions>
</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>
</pluginManagement>
</build>
+
</project>
\ No newline at end of file