Skip to content

Simplify the creation of HiveQueryRunner #18086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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 @@ -203,24 +203,28 @@ protected BaseHiveConnectorTest()
this.bucketedSession = createBucketedSession(Optional.of(new SelectedRole(ROLE, Optional.of("admin"))));
}

protected static QueryRunner createHiveQueryRunner(Map<String, String> extraProperties, Consumer<QueryRunner> additionalSetup)
@Override
protected QueryRunner createQueryRunner()
throws Exception
{
return createHiveQueryRunner(HiveQueryRunner.builder());
}

protected static QueryRunner createHiveQueryRunner(HiveQueryRunner.Builder<?> builder)
throws Exception
{
// Use faster compression codec in tests. TODO remove explicit config when default changes
verify(new HiveConfig().getHiveCompressionCodec() == HiveCompressionOption.GZIP);
String hiveCompressionCodec = HiveCompressionCodec.ZSTD.name();

DistributedQueryRunner queryRunner = HiveQueryRunner.builder()
.setExtraProperties(extraProperties)
.setAdditionalSetup(additionalSetup)
.setHiveProperties(ImmutableMap.of(
"hive.compression-codec", hiveCompressionCodec,
"hive.allow-register-partition-procedure", "true",
// Reduce writer sort buffer size to ensure SortingFileWriter gets used
"hive.writer-sort-buffer-size", "1MB",
// Make weighted split scheduling more conservative to avoid OOMs in test
"hive.minimum-assigned-split-weight", "0.5",
"hive.partition-projection-enabled", "true"))
DistributedQueryRunner queryRunner = builder
.addHiveProperty("hive.compression-codec", hiveCompressionCodec)
.addHiveProperty("hive.allow-register-partition-procedure", "true")
// Reduce writer sort buffer size to ensure SortingFileWriter gets used
.addHiveProperty("hive.writer-sort-buffer-size", "1MB")
// Make weighted split scheduling more conservative to avoid OOMs in test
.addHiveProperty("hive.minimum-assigned-split-weight", "0.5")
.addHiveProperty("hive.partition-projection-enabled", "true")
.setInitialTables(REQUIRED_TPCH_TABLES)
.setTpchBucketedCatalogEnabled(true)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@
*/
package io.trino.plugin.hive;

import com.google.common.collect.ImmutableMap;
import io.trino.testing.QueryRunner;

public class TestHiveConnectorTest
extends BaseHiveConnectorTest
{
@Override
protected QueryRunner createQueryRunner()
throws Exception
{
return BaseHiveConnectorTest.createHiveQueryRunner(ImmutableMap.of(), runner -> {});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.trino.plugin.exchange.filesystem.FileSystemExchangePlugin;
import io.trino.plugin.exchange.filesystem.containers.MinioStorage;
import io.trino.plugin.hive.BaseHiveConnectorTest;
import io.trino.plugin.hive.HiveQueryRunner;
import io.trino.testing.QueryRunner;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
Expand All @@ -41,12 +42,12 @@ protected QueryRunner createQueryRunner()
this.minioStorage = new MinioStorage("test-exchange-spooling-" + randomNameSuffix());
minioStorage.start();

return BaseHiveConnectorTest.createHiveQueryRunner(
getExtraProperties(),
runner -> {
return BaseHiveConnectorTest.createHiveQueryRunner(HiveQueryRunner.builder()
.setExtraProperties(getExtraProperties())
.setAdditionalSetup(runner -> {
runner.installPlugin(new FileSystemExchangePlugin());
runner.loadExchangeManager("filesystem", getExchangeManagerProperties(minioStorage));
});
}));
}

@Override
Expand Down