From 620d5b6bf615000a5217b5a4b30e32972fb9ffae Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Thu, 31 Mar 2022 14:50:18 +0200 Subject: [PATCH 1/2] Fix TestDeltaLakeGlueMetastore setup It was broken by 2cb84fe52454766558c9b6c2e9dfea6a4d7a5bc7. The binding was not used in production code, but was used (incorrectly) by the test code. --- .../metastore/glue/TestDeltaLakeGlueMetastore.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java index 55cbb15ab526..efb3f64e2241 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java @@ -18,10 +18,13 @@ import com.google.common.io.Files; import com.google.common.io.Resources; import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.TypeLiteral; import io.airlift.bootstrap.Bootstrap; import io.airlift.bootstrap.LifeCycleManager; import io.airlift.json.JsonModule; import io.trino.plugin.base.CatalogName; +import io.trino.plugin.base.session.SessionPropertiesProvider; import io.trino.plugin.deltalake.DeltaLakeMetadata; import io.trino.plugin.deltalake.DeltaLakeMetadataFactory; import io.trino.plugin.deltalake.DeltaLakeModule; @@ -68,6 +71,7 @@ import static io.airlift.testing.Closeables.closeAll; import static io.trino.plugin.deltalake.DeltaLakeMetadata.DELTA_STORAGE_FORMAT; import static io.trino.plugin.deltalake.DeltaLakeTableProperties.LOCATION_PROPERTY; +import static io.trino.plugin.deltalake.InternalDeltaLakeConnectorFactory.bindSessionPropertiesProvider; import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_PROPERTY; import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_VALUE; import static io.trino.plugin.hive.HiveStorageFormat.PARQUET; @@ -116,6 +120,7 @@ public void setUp() // connector modules new DeltaLakeMetastoreModule(), new DeltaLakeModule(), + binder -> bindSessionPropertiesProvider(binder, DeltaLakeSessionProperties.class), // see InternalDeltaLakeConnectorFactory // test setup binder -> { binder.bind(HdfsEnvironment.class).toInstance(HDFS_ENVIRONMENT); @@ -131,7 +136,10 @@ public void setUp() metadataFactory = injector.getInstance(DeltaLakeMetadataFactory.class); session = TestingConnectorSession.builder() - .setPropertyMetadata(injector.getInstance(DeltaLakeSessionProperties.class).getSessionProperties()) + .setPropertyMetadata(injector.getInstance(Key.get(new TypeLiteral>() {})).stream() + .map(SessionPropertiesProvider::getSessionProperties) + .flatMap(List::stream) + .collect(toImmutableList())) .build(); databaseName = "test_delta_glue" + randomName(); From 3aae9bd2e0bf9a6fd672f77c4982be0816aede7f Mon Sep 17 00:00:00 2001 From: Piotr Findeisen Date: Tue, 29 Mar 2022 15:18:33 +0200 Subject: [PATCH 2/2] Move DeltaLakeSessionProperties binding to DeltaLakeModule --- .../io/trino/plugin/deltalake/DeltaLakeModule.java | 3 +++ .../deltalake/InternalDeltaLakeConnectorFactory.java | 11 ----------- .../metastore/glue/TestDeltaLakeGlueMetastore.java | 3 --- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeModule.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeModule.java index dc5170f615f1..9a4d4ea7a6d2 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeModule.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeModule.java @@ -21,6 +21,7 @@ import com.google.inject.multibindings.Multibinder; import io.airlift.configuration.AbstractConfigurationAwareModule; import io.trino.plugin.base.CatalogName; +import io.trino.plugin.base.session.SessionPropertiesProvider; import io.trino.plugin.deltalake.metastore.DeltaLakeMetastore; import io.trino.plugin.deltalake.procedure.DropExtendedStatsProcedure; import io.trino.plugin.deltalake.procedure.VacuumProcedure; @@ -94,6 +95,8 @@ public void setup(Binder binder) Multibinder systemTableProviders = newSetBinder(binder, SystemTableProvider.class); systemTableProviders.addBinding().to(PropertiesSystemTableProvider.class).in(Scopes.SINGLETON); + newSetBinder(binder, SessionPropertiesProvider.class) + .addBinding().to(DeltaLakeSessionProperties.class).in(Scopes.SINGLETON); binder.bind(DeltaLakeTableProperties.class).in(Scopes.SINGLETON); binder.bind(DeltaLakeAnalyzeProperties.class).in(Scopes.SINGLETON); diff --git a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java index 58185d7c8669..26e0c25494be 100644 --- a/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java +++ b/plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/InternalDeltaLakeConnectorFactory.java @@ -15,11 +15,9 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableSet; -import com.google.inject.Binder; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.Scopes; import com.google.inject.TypeLiteral; import io.airlift.bootstrap.Bootstrap; import io.airlift.bootstrap.LifeCycleManager; @@ -104,7 +102,6 @@ public static Connector createConnector( binder.bind(CatalogName.class).toInstance(new CatalogName(catalogName)); newSetBinder(binder, EventListener.class); }, - binder -> bindSessionPropertiesProvider(binder, DeltaLakeSessionProperties.class), extraModule); Injector injector = app @@ -147,12 +144,4 @@ public static Connector createConnector( transactionManager); } } - - public static void bindSessionPropertiesProvider(Binder binder, Class type) - { - newSetBinder(binder, SessionPropertiesProvider.class) - .addBinding() - .to(type) - .in(Scopes.SINGLETON); - } } diff --git a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java index efb3f64e2241..5088e9a07901 100644 --- a/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java +++ b/plugin/trino-delta-lake/src/test/java/io/trino/plugin/deltalake/metastore/glue/TestDeltaLakeGlueMetastore.java @@ -28,7 +28,6 @@ import io.trino.plugin.deltalake.DeltaLakeMetadata; import io.trino.plugin.deltalake.DeltaLakeMetadataFactory; import io.trino.plugin.deltalake.DeltaLakeModule; -import io.trino.plugin.deltalake.DeltaLakeSessionProperties; import io.trino.plugin.deltalake.metastore.DeltaLakeMetastoreModule; import io.trino.plugin.hive.HdfsEnvironment; import io.trino.plugin.hive.NodeVersion; @@ -71,7 +70,6 @@ import static io.airlift.testing.Closeables.closeAll; import static io.trino.plugin.deltalake.DeltaLakeMetadata.DELTA_STORAGE_FORMAT; import static io.trino.plugin.deltalake.DeltaLakeTableProperties.LOCATION_PROPERTY; -import static io.trino.plugin.deltalake.InternalDeltaLakeConnectorFactory.bindSessionPropertiesProvider; import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_PROPERTY; import static io.trino.plugin.deltalake.metastore.HiveMetastoreBackedDeltaLakeMetastore.TABLE_PROVIDER_VALUE; import static io.trino.plugin.hive.HiveStorageFormat.PARQUET; @@ -120,7 +118,6 @@ public void setUp() // connector modules new DeltaLakeMetastoreModule(), new DeltaLakeModule(), - binder -> bindSessionPropertiesProvider(binder, DeltaLakeSessionProperties.class), // see InternalDeltaLakeConnectorFactory // test setup binder -> { binder.bind(HdfsEnvironment.class).toInstance(HDFS_ENVIRONMENT);