Skip to content
Merged
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 @@ -54,7 +54,6 @@
import io.trino.plugin.hive.TransactionalMetadataFactory;
import io.trino.plugin.hive.fs.DirectoryLister;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.SemiTransactionalHiveMetastore;
import io.trino.plugin.hive.metastore.thrift.TranslateHiveViews;
import io.trino.plugin.hive.parquet.ParquetReaderConfig;
Expand Down Expand Up @@ -93,7 +92,6 @@ public void setup(Binder binder)

configBinder(binder).bindConfig(DeltaLakeConfig.class);
configBinder(binder).bindConfig(HiveConfig.class);
binder.bind(MetastoreConfig.class).toInstance(new MetastoreConfig()); // currently not configurable
binder.bind(Key.get(boolean.class, TranslateHiveViews.class)).toInstance(false);
configBinder(binder).bindConfig(ParquetReaderConfig.class);
configBinder(binder).bindConfig(ParquetWriterConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
package io.trino.plugin.deltalake.metastore;

import com.google.inject.Binder;
import com.google.inject.Key;
import com.google.inject.Module;
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.thrift.DeltaLakeThriftMetastoreModule;
import io.trino.plugin.hive.HideDeltaLakeTables;
import io.trino.plugin.hive.metastore.DecoratedHiveMetastoreModule;
import io.trino.plugin.hive.metastore.MetastoreTypeConfig;

Expand All @@ -30,6 +32,7 @@ public class DeltaLakeMetastoreModule
@Override
protected void setup(Binder binder)
{
binder.bind(Key.get(boolean.class, HideDeltaLakeTables.class)).toInstance(false);
bindMetastoreModule("thrift", new DeltaLakeThriftMetastoreModule());
bindMetastoreModule("file", new DeltaLakeFileMetastoreModule());
bindMetastoreModule("glue", new DeltaLakeGlueMetastoreModule());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import io.trino.plugin.hive.metastore.CountingAccessHiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreFactory;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.RawHiveMetastoreFactory;
import io.trino.plugin.hive.metastore.file.FileHiveMetastore;
import io.trino.plugin.hive.metastore.file.FileHiveMetastoreConfig;
Expand Down Expand Up @@ -79,7 +78,7 @@ protected DistributedQueryRunner createQueryRunner()
HiveMetastore hiveMetastore = new FileHiveMetastore(
new NodeVersion("testversion"),
hdfsEnvironment,
new MetastoreConfig(),
false,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import io.trino.plugin.hive.metastore.Column;
import io.trino.plugin.hive.metastore.Database;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.PrincipalPrivileges;
import io.trino.plugin.hive.metastore.Storage;
import io.trino.plugin.hive.metastore.StorageFormat;
Expand Down Expand Up @@ -123,7 +122,7 @@ public void setupMetastore()
hiveMetastore = new FileHiveMetastore(
new NodeVersion("test_version"),
hdfsEnvironment,
new MetastoreConfig(),
false,
new FileHiveMetastoreConfig()
.setCatalogDirectory(metastoreDir.toURI().toString())
.setMetastoreUser("test"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import alluxio.client.table.TableMasterClient;
import alluxio.conf.PropertyKey;
import io.trino.plugin.hive.authentication.NoHdfsAuthentication;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.alluxio.AlluxioHiveMetastore;
import io.trino.plugin.hive.metastore.alluxio.AlluxioHiveMetastoreConfig;
import io.trino.plugin.hive.metastore.alluxio.AlluxioMetastoreModule;
Expand Down Expand Up @@ -61,7 +61,7 @@ public void setup(String host, String port, int hiveVersionMajor, String timeZon
alluxioConfig.setMasterAddress(this.alluxioAddress);
TableMasterClient client = AlluxioMetastoreModule.createCatalogMasterClient(alluxioConfig);
hdfsEnvironment = new HdfsEnvironment(createTestHdfsConfiguration(), new HdfsConfig(), new NoHdfsAuthentication());
setup(SCHEMA, hiveConfig, new AlluxioHiveMetastore(client, new MetastoreConfig()), hdfsEnvironment);
setup(SCHEMA, hiveConfig, new AlluxioHiveMetastore(client, new HiveMetastoreConfig()), hdfsEnvironment);
}

private int getHiveVersionMajor()
Expand Down
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;

import javax.inject.Qualifier;

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})
@Qualifier
public @interface HideDeltaLakeTables
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import io.trino.plugin.base.CatalogName;
import io.trino.plugin.hive.fs.DirectoryLister;
import io.trino.plugin.hive.fs.TransactionScopeCachingDirectoryLister;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.HiveMetastoreFactory;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.SemiTransactionalHiveMetastore;
import io.trino.plugin.hive.security.AccessControlMetadataFactory;
import io.trino.plugin.hive.statistics.MetastoreHiveStatisticsProvider;
Expand Down Expand Up @@ -77,7 +77,7 @@ public class HiveMetadataFactory
public HiveMetadataFactory(
CatalogName catalogName,
HiveConfig hiveConfig,
MetastoreConfig metastoreConfig,
HiveMetastoreConfig hiveMetastoreConfig,
HiveMetastoreFactory metastoreFactory,
HdfsEnvironment hdfsEnvironment,
HivePartitionManager partitionManager,
Expand Down Expand Up @@ -111,7 +111,7 @@ public HiveMetadataFactory(
hiveConfig.isHiveViewsRunAsInvoker(),
hiveConfig.getPerTransactionMetastoreCacheMaximumSize(),
hiveConfig.getHiveTransactionHeartbeatInterval(),
metastoreConfig.isHideDeltaLakeTables(),
hiveMetastoreConfig.isHideDeltaLakeTables(),
typeManager,
metadataProvider,
locationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import io.airlift.event.client.EventClient;
import io.trino.plugin.base.CatalogName;
import io.trino.plugin.hive.fs.CachingDirectoryLister;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.thrift.TranslateHiveViews;
import io.trino.plugin.hive.orc.OrcFileWriterFactory;
import io.trino.plugin.hive.orc.OrcPageSourceFactory;
Expand Down Expand Up @@ -61,7 +61,7 @@ public class HiveModule
public void configure(Binder binder)
{
configBinder(binder).bindConfig(HiveConfig.class);
configBinder(binder).bindConfig(MetastoreConfig.class);
configBinder(binder).bindConfig(HiveMetastoreConfig.class);

binder.bind(HiveSessionProperties.class).in(Scopes.SINGLETON);
binder.bind(HiveTableProperties.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;

public class MetastoreConfig
public class HiveMetastoreConfig
{
private boolean hideDeltaLakeTables;

Expand All @@ -27,7 +27,7 @@ public boolean isHideDeltaLakeTables()

@Config("hive.hide-delta-lake-tables")
@ConfigDescription("Hide Delta Lake tables in table listings")
public MetastoreConfig setHideDeltaLakeTables(boolean hideDeltaLakeTables)
public HiveMetastoreConfig setHideDeltaLakeTables(boolean hideDeltaLakeTables)
{
this.hideDeltaLakeTables = hideDeltaLakeTables;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import io.airlift.configuration.AbstractConfigurationAwareModule;
import io.trino.plugin.hive.HideDeltaLakeTables;
import io.trino.plugin.hive.metastore.file.FileMetastoreModule;
import io.trino.plugin.hive.metastore.glue.GlueMetastoreModule;
import io.trino.plugin.hive.metastore.thrift.ThriftMetastoreModule;
Expand Down Expand Up @@ -80,4 +83,12 @@ protected void setup(Binder binder)
}
};
}

@HideDeltaLakeTables
@Singleton
@Provides
public boolean hideDeltaLakeTables(HiveMetastoreConfig hiveMetastoreConfig)
{
return hiveMetastoreConfig.isHideDeltaLakeTables();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import io.trino.plugin.hive.metastore.Database;
import io.trino.plugin.hive.metastore.HiveColumnStatistics;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.HivePrincipal;
import io.trino.plugin.hive.metastore.HivePrivilegeInfo;
import io.trino.plugin.hive.metastore.HivePrivilegeInfo.HivePrivilege;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.Partition;
import io.trino.plugin.hive.metastore.PartitionWithStatistics;
import io.trino.plugin.hive.metastore.PrincipalPrivileges;
Expand Down Expand Up @@ -71,11 +71,11 @@ public class AlluxioHiveMetastore
{
private final TableMasterClient client;

public AlluxioHiveMetastore(TableMasterClient client, MetastoreConfig metastoreConfig)
public AlluxioHiveMetastore(TableMasterClient client, HiveMetastoreConfig hiveMetastoreConfig)
{
this.client = requireNonNull(client, "client is null");
requireNonNull(metastoreConfig, "metastoreConfig is null");
checkArgument(!metastoreConfig.isHideDeltaLakeTables(), "Hiding Delta Lake tables is not supported"); // TODO
requireNonNull(hiveMetastoreConfig, "hiveMetastoreConfig is null");
checkArgument(!hiveMetastoreConfig.isHideDeltaLakeTables(), "Hiding Delta Lake tables is not supported"); // TODO
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

import alluxio.client.table.TableMasterClient;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.HiveMetastoreFactory;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.spi.security.ConnectorIdentity;

import javax.inject.Inject;
Expand All @@ -29,10 +29,10 @@ public class AlluxioHiveMetastoreFactory
private final AlluxioHiveMetastore metastore;

@Inject
public AlluxioHiveMetastoreFactory(TableMasterClient client, MetastoreConfig metastoreConfig)
public AlluxioHiveMetastoreFactory(TableMasterClient client, HiveMetastoreConfig hiveMetastoreConfig)
{
// Alluxio metastore does not support impersonation, so just create a single shared instance
metastore = new AlluxioHiveMetastore(client, metastoreConfig);
metastore = new AlluxioHiveMetastore(client, hiveMetastoreConfig);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
import io.trino.plugin.hive.metastore.Database;
import io.trino.plugin.hive.metastore.HiveColumnStatistics;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreConfig;
import io.trino.plugin.hive.metastore.HivePrincipal;
import io.trino.plugin.hive.metastore.HivePrivilegeInfo;
import io.trino.plugin.hive.metastore.HivePrivilegeInfo.HivePrivilege;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.metastore.Partition;
import io.trino.plugin.hive.metastore.PartitionWithStatistics;
import io.trino.plugin.hive.metastore.PrincipalPrivileges;
Expand Down Expand Up @@ -165,21 +165,21 @@ public static FileHiveMetastore createTestingFileHiveMetastore(File catalogDirec
return new FileHiveMetastore(
new NodeVersion("testversion"),
hdfsEnvironment,
new MetastoreConfig(),
new HiveMetastoreConfig().isHideDeltaLakeTables(),
new FileHiveMetastoreConfig()
.setCatalogDirectory(catalogDirectory.toURI().toString())
.setMetastoreUser("test"));
}

public FileHiveMetastore(NodeVersion nodeVersion, HdfsEnvironment hdfsEnvironment, MetastoreConfig metastoreConfig, FileHiveMetastoreConfig config)
public FileHiveMetastore(NodeVersion nodeVersion, HdfsEnvironment hdfsEnvironment, boolean hideDeltaLakeTables, FileHiveMetastoreConfig config)
{
this.currentVersion = requireNonNull(nodeVersion, "nodeVersion is null").toString();
requireNonNull(config, "config is null");
this.versionCompatibility = requireNonNull(config.getVersionCompatibility(), "config.getVersionCompatibility() is null");
this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
this.catalogDirectory = new Path(requireNonNull(config.getCatalogDirectory(), "catalogDirectory is null"));
this.hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(config.getMetastoreUser()));
this.hideDeltaLakeTables = requireNonNull(metastoreConfig, "metastoreConfig is null").isHideDeltaLakeTables();
this.hideDeltaLakeTables = hideDeltaLakeTables;
try {
metadataFileSystem = hdfsEnvironment.getFileSystem(hdfsContext, this.catalogDirectory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
package io.trino.plugin.hive.metastore.file;

import io.trino.plugin.hive.HdfsEnvironment;
import io.trino.plugin.hive.HideDeltaLakeTables;
import io.trino.plugin.hive.NodeVersion;
import io.trino.plugin.hive.metastore.HiveMetastore;
import io.trino.plugin.hive.metastore.HiveMetastoreFactory;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.spi.security.ConnectorIdentity;

import javax.inject.Inject;
Expand All @@ -30,10 +30,10 @@ public class FileHiveMetastoreFactory
private final FileHiveMetastore metastore;

@Inject
public FileHiveMetastoreFactory(NodeVersion nodeVersion, HdfsEnvironment hdfsEnvironment, MetastoreConfig metastoreConfig, FileHiveMetastoreConfig config)
public FileHiveMetastoreFactory(NodeVersion nodeVersion, HdfsEnvironment hdfsEnvironment, @HideDeltaLakeTables boolean hideDeltaLakeTables, FileHiveMetastoreConfig config)
{
// file metastore does not support impersonation, so just create a single shared instance
metastore = new FileHiveMetastore(nodeVersion, hdfsEnvironment, metastoreConfig, config);
metastore = new FileHiveMetastore(nodeVersion, hdfsEnvironment, hideDeltaLakeTables, config);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package io.trino.plugin.hive.metastore.glue;

import com.amazonaws.services.glue.model.Table;
import io.trino.plugin.hive.metastore.MetastoreConfig;
import io.trino.plugin.hive.HideDeltaLakeTables;

import javax.inject.Inject;
import javax.inject.Provider;
Expand All @@ -25,7 +25,6 @@
import static com.google.common.base.MoreObjects.firstNonNull;
import static io.trino.plugin.hive.util.HiveUtil.DELTA_LAKE_PROVIDER;
import static io.trino.plugin.hive.util.HiveUtil.SPARK_TABLE_PROVIDER_KEY;
import static java.util.Objects.requireNonNull;
import static java.util.function.Predicate.not;

public class DefaultGlueMetastoreTableFilterProvider
Expand All @@ -34,10 +33,9 @@ public class DefaultGlueMetastoreTableFilterProvider
private final boolean hideDeltaLakeTables;

@Inject
public DefaultGlueMetastoreTableFilterProvider(MetastoreConfig metastoreConfig)
public DefaultGlueMetastoreTableFilterProvider(@HideDeltaLakeTables boolean hideDeltaLakeTables)
{
requireNonNull(metastoreConfig, "metastoreConfig is null");
this.hideDeltaLakeTables = metastoreConfig.isHideDeltaLakeTables();
this.hideDeltaLakeTables = hideDeltaLakeTables;
}

@Override
Expand Down
Loading