Skip to content

Commit

Permalink
Remove FileHiveMetastore constructor overload
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Oct 6, 2020
1 parent a1d899b commit 772515c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,23 @@ public class FileHiveMetastore
public static FileHiveMetastore createTestingFileHiveMetastore(File catalogDirectory)
{
HdfsConfig hdfsConfig = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());
return new FileHiveMetastore(hdfsEnvironment, catalogDirectory.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
return new FileHiveMetastore(
hdfsEnvironment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(catalogDirectory.toURI().toString())
.setMetastoreUser("test"));
}

@Inject
public FileHiveMetastore(HdfsEnvironment hdfsEnvironment, FileHiveMetastoreConfig config)
{
this(hdfsEnvironment, config.getCatalogDirectory(), config.getMetastoreUser(), config.isAssumeCanonicalPartitionKeys());
}

public FileHiveMetastore(HdfsEnvironment hdfsEnvironment, String catalogDirectory, String metastoreUser, boolean assumeCanonicalPartitionKeys)
{
this.hdfsEnvironment = requireNonNull(hdfsEnvironment, "hdfsEnvironment is null");
this.catalogDirectory = new Path(requireNonNull(catalogDirectory, "baseDirectory is null"));
this.hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(metastoreUser));
this.assumeCanonicalPartitionKeys = assumeCanonicalPartitionKeys;
requireNonNull(config, "config is null");
this.catalogDirectory = new Path(requireNonNull(config.getCatalogDirectory(), "catalogDirectory is null"));
this.hdfsContext = new HdfsContext(ConnectorIdentity.ofUser(config.getMetastoreUser()));
this.assumeCanonicalPartitionKeys = config.isAssumeCanonicalPartitionKeys();
try {
metadataFileSystem = hdfsEnvironment.getFileSystem(hdfsContext, this.catalogDirectory);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.prestosql.plugin.hive.metastore.Database;
import io.prestosql.plugin.hive.metastore.HiveMetastore;
import io.prestosql.plugin.hive.metastore.file.FileHiveMetastore;
import io.prestosql.plugin.hive.metastore.file.FileHiveMetastoreConfig;
import io.prestosql.plugin.hive.testing.TestingHivePlugin;
import io.prestosql.plugin.tpch.TpchPlugin;
import io.prestosql.spi.security.Identity;
Expand Down Expand Up @@ -90,7 +91,12 @@ public static class Builder
private List<TpchTable<?>> initialTables = ImmutableList.of();
private Function<DistributedQueryRunner, HiveMetastore> metastore = queryRunner -> {
File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("hive_data").toFile();
return new FileHiveMetastore(HDFS_ENVIRONMENT, baseDir.toURI().toString(), "test", true);
return new FileHiveMetastore(
HDFS_ENVIRONMENT,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test")
.setAssumeCanonicalPartitionKeys(true));
};
private Module module = EMPTY_MODULE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ public class TestHiveFileMetastore
protected HiveMetastore createMetastore(File tempDir)
{
File baseDir = new File(tempDir, "metastore");
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
return new FileHiveMetastore(HDFS_ENVIRONMENT, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
return new FileHiveMetastore(
HDFS_ENVIRONMENT,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ protected Optional<LocalQueryRunner> createLocalQueryRunner()
{
baseDir = Files.createTempDir();
HdfsConfig config = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration configuration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config), ImmutableSet.of());
HdfsEnvironment environment = new HdfsEnvironment(configuration, config, new NoHdfsAuthentication());

metastore = new FileHiveMetastore(environment, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
metastore = new FileHiveMetastore(
environment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));
Database database = Database.builder()
.setDatabaseName(SCHEMA_NAME)
.setOwnerName("public")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,14 @@ protected LocalQueryRunner createLocalQueryRunner()
{
baseDir = Files.createTempDir();
HdfsConfig config = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration configuration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(config), ImmutableSet.of());
HdfsEnvironment environment = new HdfsEnvironment(configuration, config, new NoHdfsAuthentication());

HiveMetastore metastore = new FileHiveMetastore(environment, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
HiveMetastore metastore = new FileHiveMetastore(
environment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));
Database database = Database.builder()
.setDatabaseName(SCHEMA_NAME)
.setOwnerName("public")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ protected DistributedQueryRunner createQueryRunner()
File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();

HdfsConfig hdfsConfig = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());

metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
metastore = new FileHiveMetastore(
hdfsEnvironment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));

queryRunner.installPlugin(new TestingIcebergPlugin(metastore));
queryRunner.createCatalog("iceberg", "iceberg");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ protected QueryRunner createQueryRunner()
File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();

HdfsConfig hdfsConfig = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());

HiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
HiveMetastore metastore = new FileHiveMetastore(
hdfsEnvironment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));

queryRunner.installPlugin(new TestingIcebergPlugin(metastore));
queryRunner.createCatalog("iceberg", "iceberg");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,14 @@ protected DistributedQueryRunner createQueryRunner()
File baseDir = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data").toFile();

HdfsConfig hdfsConfig = new HdfsConfig();
FileHiveMetastoreConfig metastoreConfig = new FileHiveMetastoreConfig();
HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hdfsConfig), ImmutableSet.of());
HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hdfsConfig, new NoHdfsAuthentication());

HiveMetastore metastore = new FileHiveMetastore(hdfsEnvironment, baseDir.toURI().toString(), "test", metastoreConfig.isAssumeCanonicalPartitionKeys());
HiveMetastore metastore = new FileHiveMetastore(
hdfsEnvironment,
new FileHiveMetastoreConfig()
.setCatalogDirectory(baseDir.toURI().toString())
.setMetastoreUser("test"));

queryRunner.installPlugin(new TestingIcebergPlugin(metastore));
queryRunner.createCatalog("iceberg", "iceberg");
Expand Down

0 comments on commit 772515c

Please sign in to comment.