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 @@ -105,7 +105,7 @@ protected String getExpectedHiveCreateSchema(String catalogName)
" location = '%s'\n" +
")";

return format(expectedHiveCreateSchema, catalogName, schema, dataDirectory.toUri().toString().replaceFirst("/$", ""));
return format(expectedHiveCreateSchema, catalogName, schema, dataDirectory.toUri());
}

@Override
Expand All @@ -115,6 +115,6 @@ protected String getExpectedDeltaLakeCreateSchema(String catalogName)
"WITH (\n" +
" location = '%s'\n" +
")";
return format(expectedDeltaLakeCreateSchema, catalogName, schema, dataDirectory.toUri().toString().replaceFirst("/$", ""));
return format(expectedDeltaLakeCreateSchema, catalogName, schema, dataDirectory.toUri());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.trino.plugin.hive.BaseS3AndGlueMetastoreTest;
import io.trino.testing.QueryRunner;

import java.nio.file.Path;
import java.net.URI;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand All @@ -41,7 +41,7 @@ public TestDeltaS3AndGlueMetastoreTest()
protected QueryRunner createQueryRunner()
throws Exception
{
metastore = createTestingGlueHiveMetastore(Path.of(schemaPath()));
metastore = createTestingGlueHiveMetastore(URI.create(schemaPath()));
QueryRunner queryRunner = DeltaLakeQueryRunner.builder()
.setCatalogName(DELTA_CATALOG)
.setDeltaProperties(ImmutableMap.<String, String>builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import io.trino.testing.QueryRunner;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.net.URI;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -51,7 +51,7 @@ public TestHiveS3AndGlueMetastoreTest()
protected QueryRunner createQueryRunner()
throws Exception
{
metastore = createTestingGlueHiveMetastore(Path.of(schemaPath()));
metastore = createTestingGlueHiveMetastore(URI.create(schemaPath()));

Session session = createSession(Optional.of(new SelectedRole(ROLE, Optional.of("admin"))));
QueryRunner queryRunner = HiveQueryRunner.builder(session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.io.IOException;
import java.nio.file.Path;

import static com.google.common.base.Verify.verify;
import static com.google.common.io.MoreFiles.deleteRecursively;
import static com.google.common.io.RecursiveDeleteOption.ALLOW_INSECURE;
import static io.trino.plugin.hive.metastore.glue.TestingGlueHiveMetastore.createTestingGlueHiveMetastore;
Expand All @@ -34,7 +33,6 @@ final class TestGlueHiveMetastore
throws IOException
{
tempDir = createTempDirectory("test");
verify(tempDir.toFile().mkdirs());
metastore = createTestingGlueHiveMetastore(tempDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,40 @@
import com.amazonaws.services.glue.AWSGlueAsync;
import com.google.common.collect.ImmutableSet;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;

import static com.google.common.base.Verify.verify;
import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static io.trino.plugin.hive.HiveTestUtils.HDFS_FILE_SYSTEM_FACTORY;
import static io.trino.plugin.hive.metastore.glue.GlueClientUtil.createAsyncGlueClient;
import static java.nio.file.Files.createDirectories;
import static java.nio.file.Files.exists;
import static java.nio.file.Files.isDirectory;

public final class TestingGlueHiveMetastore
{
private TestingGlueHiveMetastore() {}

public static GlueHiveMetastore createTestingGlueHiveMetastore(Path defaultWarehouseDir)
{
if (!exists(defaultWarehouseDir)) {
try {
createDirectories(defaultWarehouseDir);
}
catch (IOException e) {
throw new RuntimeException("Could not create directory: %s".formatted(defaultWarehouseDir), e);
}
}
verify(isDirectory(defaultWarehouseDir), "%s is not a directory", defaultWarehouseDir);
return createTestingGlueHiveMetastore(defaultWarehouseDir.toUri());
}

public static GlueHiveMetastore createTestingGlueHiveMetastore(URI warehouseUri)
{
GlueHiveMetastoreConfig glueConfig = new GlueHiveMetastoreConfig()
.setDefaultWarehouseDir(defaultWarehouseDir.toUri().toString());
.setDefaultWarehouseDir(warehouseUri.toString());
GlueMetastoreStats stats = new GlueMetastoreStats();
return new GlueHiveMetastore(
HDFS_FILE_SYSTEM_FACTORY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.trino.testing.QueryRunner;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.net.URI;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
Expand All @@ -42,7 +42,7 @@ public TestIcebergS3AndGlueMetastoreTest()
protected QueryRunner createQueryRunner()
throws Exception
{
metastore = createTestingGlueHiveMetastore(Path.of(schemaPath()));
metastore = createTestingGlueHiveMetastore(URI.create(schemaPath()));
QueryRunner queryRunner = IcebergQueryRunner.builder()
.setIcebergProperties(ImmutableMap.<String, String>builder()
.put("iceberg.catalog.type", "glue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected String getExpectedHiveCreateSchema(String catalogName)
" location = '%s'\n" +
")";

return format(expectedHiveCreateSchema, catalogName, schema, dataDirectory.toUri().toString().replaceFirst("/$", ""));
return format(expectedHiveCreateSchema, catalogName, schema, dataDirectory.toUri());
}

@Override
Expand All @@ -140,6 +140,6 @@ protected String getExpectedIcebergCreateSchema(String catalogName)
"WITH (\n" +
" location = '%s'\n" +
")";
return format(expectedIcebergCreateSchema, catalogName, schema, dataDirectory.toUri().toString().replaceFirst("/$", ""));
return format(expectedIcebergCreateSchema, catalogName, schema, dataDirectory.toUri());
}
}