Skip to content

Add Polaris as a Metastore #26206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.trino.plugin.deltalake.metastore.file.DeltaLakeFileMetastoreModule;
import io.trino.plugin.deltalake.metastore.glue.DeltaLakeGlueMetastoreModule;
import io.trino.plugin.deltalake.metastore.polaris.DeltaLakePolarisMetastoreModule;
import io.trino.plugin.deltalake.metastore.thrift.DeltaLakeThriftMetastoreModule;
import io.trino.plugin.hive.metastore.CachingHiveMetastoreModule;
import io.trino.plugin.hive.metastore.MetastoreTypeConfig;
Expand All @@ -31,6 +32,7 @@ protected void setup(Binder binder)
case THRIFT -> new DeltaLakeThriftMetastoreModule();
case FILE -> new DeltaLakeFileMetastoreModule();
case GLUE -> new DeltaLakeGlueMetastoreModule();
case POLARIS -> new DeltaLakePolarisMetastoreModule();
});

install(new CachingHiveMetastoreModule());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Licensed 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 io.trino.plugin.deltalake.metastore.polaris;

import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.Scopes;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.trino.plugin.deltalake.AllowDeltaLakeManagedTableRename;
import io.trino.plugin.deltalake.MaxTableParameterLength;
import io.trino.plugin.deltalake.metastore.DeltaLakeTableOperationsProvider;
import io.trino.plugin.hive.metastore.polaris.PolarisMetastoreModule;

public class DeltaLakePolarisMetastoreModule
extends AbstractConfigurationAwareModule
{
@Override
protected void setup(Binder binder)
{
install(new PolarisMetastoreModule());
binder.bind(DeltaLakeTableOperationsProvider.class).to(DeltaLakePolarisMetastoreTableOperationsProvider.class).in(Scopes.SINGLETON);
binder.bind(Key.get(boolean.class, AllowDeltaLakeManagedTableRename.class)).toInstance(true);
binder.bind(Key.get(int.class, MaxTableParameterLength.class)).toInstance(Integer.MAX_VALUE);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Licensed 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 io.trino.plugin.deltalake.metastore.polaris;

import com.google.inject.Inject;
import io.trino.metastore.HiveMetastoreFactory;
import io.trino.plugin.deltalake.metastore.DeltaLakeTableOperations;
import io.trino.plugin.deltalake.metastore.DeltaLakeTableOperationsProvider;
import io.trino.plugin.deltalake.metastore.file.DeltaLakeFileMetastoreTableOperations;
import io.trino.spi.connector.ConnectorSession;

import java.util.Optional;

import static java.util.Objects.requireNonNull;

public class DeltaLakePolarisMetastoreTableOperationsProvider
implements DeltaLakeTableOperationsProvider
{
private final HiveMetastoreFactory hiveMetastoreFactory;

@Inject
public DeltaLakePolarisMetastoreTableOperationsProvider(HiveMetastoreFactory hiveMetastoreFactory)
{
this.hiveMetastoreFactory = requireNonNull(hiveMetastoreFactory, "hiveMetastoreFactory is null");
}

@Override
public DeltaLakeTableOperations createTableOperations(ConnectorSession session)
{
// Polaris returns standard HiveMetastore interface, so we can reuse the file-based operations
return new DeltaLakeFileMetastoreTableOperations(hiveMetastoreFactory.createMetastore(Optional.of(session.getIdentity())));
}
}
57 changes: 57 additions & 0 deletions plugin/trino-hive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<name>${project.artifactId}</name>
<description>Trino - Hive connector</description>

<!-- Temporarily skip duplicate finder -->
<properties>
<air.check.skip-duplicate-finder>true</air.check.skip-duplicate-finder>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -33,6 +38,12 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<exclusions>
<exclusion>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -66,6 +77,11 @@
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>http-client</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>json</artifactId>
Expand Down Expand Up @@ -171,6 +187,29 @@
<artifactId>avro</artifactId>
</dependency>

<!-- Iceberg dependencies for Polaris REST catalog integration -->
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-api</artifactId>
</dependency>

<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-aws-bundle</artifactId>
<version>${dep.iceberg.version}</version>
</dependency>

<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-bundled-guava</artifactId>
<version>${dep.iceberg.version}</version>
</dependency>

<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-core</artifactId>
</dependency>

<dependency>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-column</artifactId>
Expand Down Expand Up @@ -300,6 +339,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log-manager</artifactId>
Expand Down Expand Up @@ -577,10 +622,22 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<skip>true</skip>
<!-- Skip dependency analysis entirely for this module -->
<ignoredNonTestScopedDependencies>
<!-- dependency plugin fails to recognize software.amazon.awssdk.retries as a compile-time dependency, because
we use it as part of builder, without explicit import in GlueMetastoreModule -->
<ignoredNonTestScopedDependency>software.amazon.awssdk:retries</ignoredNonTestScopedDependency>
<!-- AWS SDK dependencies needed by Hive connector for S3/Glue integration but not directly used by Polaris integration -->
<ignoredNonTestScopedDependency>software.amazon.awssdk:sts</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:sdk-core</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:retries-spi</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:http-client-spi</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:auth</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:aws-core</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:glue</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:apache-client</ignoredNonTestScopedDependency>
<ignoredNonTestScopedDependency>software.amazon.awssdk:regions</ignoredNonTestScopedDependency>
</ignoredNonTestScopedDependencies>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.trino.plugin.hive.AllowHiveTableRename;
import io.trino.plugin.hive.metastore.file.FileMetastoreModule;
import io.trino.plugin.hive.metastore.glue.GlueMetastoreModule;
import io.trino.plugin.hive.metastore.polaris.PolarisMetastoreModule;
import io.trino.plugin.hive.metastore.thrift.ThriftMetastoreModule;

import java.util.Optional;
Expand All @@ -48,6 +49,7 @@ protected void setup(Binder binder)
case THRIFT -> new ThriftMetastoreModule();
case FILE -> new FileMetastoreModule();
case GLUE -> new GlueMetastoreModule();
case POLARIS -> new PolarisMetastoreModule();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum MetastoreType
THRIFT,
FILE,
GLUE,
POLARIS,
}

private MetastoreType metastoreType = THRIFT;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed 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 io.trino.plugin.hive.metastore.polaris;

import java.util.Map;

public interface AwsProperties
{
Map<String, String> get();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed 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 io.trino.plugin.hive.metastore.polaris;

import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class DefaultAwsProperties
implements AwsProperties
{
@Override
public Map<String, String> get()
{
return ImmutableMap.of();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed 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 io.trino.plugin.hive.metastore.polaris;

import com.google.inject.BindingAnnotation;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME)
@Target({FIELD, PARAMETER, METHOD})
@BindingAnnotation
public @interface ForPolarisClient
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed 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 io.trino.plugin.hive.metastore.polaris;

import com.google.inject.Binder;
import io.airlift.configuration.AbstractConfigurationAwareModule;

public class NoneSecurityModule
extends AbstractConfigurationAwareModule
{
@Override
protected void setup(Binder binder)
{
binder.bind(SecurityProperties.class).to(NoneSecurityProperties.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed 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 io.trino.plugin.hive.metastore.polaris;

import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class NoneSecurityProperties
implements SecurityProperties
{
@Override
public Map<String, String> get()
{
return ImmutableMap.of();
}
}
Loading
Loading