diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetastoreModule.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergCatalogModule.java similarity index 79% rename from plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetastoreModule.java rename to plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergCatalogModule.java index 443080ce1ca4..846b320a6d83 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetastoreModule.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergCatalogModule.java @@ -15,13 +15,14 @@ import com.google.inject.Binder; import com.google.inject.Module; +import com.google.inject.Scopes; import io.airlift.configuration.AbstractConfigurationAwareModule; import io.trino.plugin.hive.metastore.HiveMetastore; import io.trino.plugin.hive.metastore.cache.CachingHiveMetastore; import io.trino.plugin.hive.metastore.cache.CachingHiveMetastoreModule; import io.trino.plugin.hive.metastore.cache.ForCachingHiveMetastore; -import io.trino.plugin.hive.metastore.file.FileMetastoreModule; -import io.trino.plugin.hive.metastore.thrift.ThriftMetastoreModule; +import io.trino.plugin.iceberg.catalog.file.IcebergFileMetastoreCatalogModule; +import io.trino.plugin.iceberg.catalog.hms.IcebergHiveMetastoreCatalogModule; import javax.inject.Inject; @@ -32,12 +33,12 @@ import static io.trino.plugin.iceberg.CatalogType.TESTING_FILE_METASTORE; import static java.util.Objects.requireNonNull; -public class IcebergMetastoreModule +public class IcebergCatalogModule extends AbstractConfigurationAwareModule { private final Optional metastore; - public IcebergMetastoreModule(Optional metastore) + public IcebergCatalogModule(Optional metastore) { this.metastore = requireNonNull(metastore, "metastore is null"); } @@ -48,10 +49,11 @@ protected void setup(Binder binder) if (metastore.isPresent()) { binder.bind(HiveMetastore.class).annotatedWith(ForCachingHiveMetastore.class).toInstance(metastore.get()); install(new CachingHiveMetastoreModule()); + binder.bind(HiveTableOperationsProvider.class).in(Scopes.SINGLETON); } else { - bindMetastoreModule(HIVE_METASTORE, new ThriftMetastoreModule()); - bindMetastoreModule(TESTING_FILE_METASTORE, new FileMetastoreModule()); + bindCatalogModule(HIVE_METASTORE, new IcebergHiveMetastoreCatalogModule()); + bindCatalogModule(TESTING_FILE_METASTORE, new IcebergFileMetastoreCatalogModule()); // TODO add support for Glue metastore } @@ -69,7 +71,7 @@ public MetastoreValidator(HiveMetastore metastore) } } - private void bindMetastoreModule(CatalogType catalogType, Module module) + private void bindCatalogModule(CatalogType catalogType, Module module) { install(conditionalModule( IcebergConfig.class, diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java index 7ba247f1e197..894458053452 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergModule.java @@ -74,9 +74,6 @@ public void configure(Binder binder) binder.bind(FileFormatDataSourceStats.class).in(Scopes.SINGLETON); newExporter(binder).export(FileFormatDataSourceStats.class).withGeneratedName(); - // TODO inject table operations based on IcebergConfig.getCatalogType - binder.bind(HiveTableOperationsProvider.class).in(Scopes.SINGLETON); - binder.bind(IcebergFileWriterFactory.class).in(Scopes.SINGLETON); newExporter(binder).export(IcebergFileWriterFactory.class).withGeneratedName(); diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/InternalIcebergConnectorFactory.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/InternalIcebergConnectorFactory.java index dfe0a6329b70..d1fce63e67d7 100644 --- a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/InternalIcebergConnectorFactory.java +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/InternalIcebergConnectorFactory.java @@ -77,7 +77,7 @@ public static Connector createConnector( new ConnectorObjectNameGeneratorModule(catalogName, "io.trino.plugin.iceberg", "trino.plugin.iceberg"), new JsonModule(), new IcebergModule(), - new IcebergMetastoreModule(metastore), + new IcebergCatalogModule(metastore), new HiveHdfsModule(), new HiveS3Module(), new HiveGcsModule(), diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/file/IcebergFileMetastoreCatalogModule.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/file/IcebergFileMetastoreCatalogModule.java new file mode 100644 index 000000000000..9f7f033e2070 --- /dev/null +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/file/IcebergFileMetastoreCatalogModule.java @@ -0,0 +1,33 @@ +/* + * 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.iceberg.catalog.file; + +import com.google.inject.Binder; +import com.google.inject.Scopes; +import io.airlift.configuration.AbstractConfigurationAwareModule; +import io.trino.plugin.hive.metastore.file.FileMetastoreModule; +import io.trino.plugin.iceberg.HiveTableOperationsProvider; + +public class IcebergFileMetastoreCatalogModule + extends AbstractConfigurationAwareModule +{ + @Override + protected void setup(Binder binder) + { + install(new FileMetastoreModule()); + + // TODO inject table operations based on IcebergConfig.getCatalogType + binder.bind(HiveTableOperationsProvider.class).in(Scopes.SINGLETON); + } +} diff --git a/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/IcebergHiveMetastoreCatalogModule.java b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/IcebergHiveMetastoreCatalogModule.java new file mode 100644 index 000000000000..9a1ce1949165 --- /dev/null +++ b/plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/catalog/hms/IcebergHiveMetastoreCatalogModule.java @@ -0,0 +1,33 @@ +/* + * 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.iceberg.catalog.hms; + +import com.google.inject.Binder; +import com.google.inject.Scopes; +import io.airlift.configuration.AbstractConfigurationAwareModule; +import io.trino.plugin.hive.metastore.thrift.ThriftMetastoreModule; +import io.trino.plugin.iceberg.HiveTableOperationsProvider; + +public class IcebergHiveMetastoreCatalogModule + extends AbstractConfigurationAwareModule +{ + @Override + protected void setup(Binder binder) + { + install(new ThriftMetastoreModule()); + + // TODO inject table operations based on IcebergConfig.getCatalogType + binder.bind(HiveTableOperationsProvider.class).in(Scopes.SINGLETON); + } +}