Skip to content

Commit

Permalink
Use builder pattern for IcebergQueryRunner
Browse files Browse the repository at this point in the history
Additionally, add support for tracking catalog properties
added to iceberg. This can be useful for tests that may
require their own catalogs
  • Loading branch information
ZacBlanco committed Feb 8, 2025
1 parent 2005b0b commit 686e6b3
Show file tree
Hide file tree
Showing 31 changed files with 345 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.facebook.presto.iceberg;

import com.facebook.presto.tests.DistributedQueryRunner;
import com.google.common.collect.ImmutableMap;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
Expand All @@ -27,12 +26,9 @@
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.VerboseMode;

import java.util.Optional;
import java.util.OptionalInt;

import static com.facebook.presto.iceberg.CatalogType.HADOOP;
import static com.facebook.presto.iceberg.FileFormat.PARQUET;
import static com.facebook.presto.iceberg.IcebergQueryRunner.createIcebergQueryRunner;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openjdk.jmh.annotations.Mode.AverageTime;
import static org.openjdk.jmh.annotations.Scope.Benchmark;
Expand All @@ -50,14 +46,11 @@ public class BenchmarkIcebergHadoopCatalog
public DistributedQueryRunner getQueryRunner()
{
try {
return createIcebergQueryRunner(
ImmutableMap.of(),
ImmutableMap.of("iceberg.catalog.type", HADOOP.name()),
PARQUET,
false,
true,
OptionalInt.of(1),
Optional.empty());
return IcebergQueryRunner.builder()
.setCatalogType(HADOOP)
.setNodeCount(OptionalInt.of(4))
.build()
.getQueryRunner();
}
catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.facebook.presto.iceberg;

import com.facebook.presto.tests.DistributedQueryRunner;
import com.google.common.collect.ImmutableMap;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
Expand All @@ -27,11 +26,9 @@
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.VerboseMode;

import java.util.Optional;
import java.util.OptionalInt;

import static com.facebook.presto.iceberg.FileFormat.PARQUET;
import static com.facebook.presto.iceberg.IcebergQueryRunner.createIcebergQueryRunner;
import static com.facebook.presto.iceberg.CatalogType.HIVE;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openjdk.jmh.annotations.Mode.AverageTime;
import static org.openjdk.jmh.annotations.Scope.Benchmark;
Expand All @@ -49,14 +46,10 @@ public class BenchmarkIcebergHiveCatalog
public DistributedQueryRunner getQueryRunner()
{
try {
return createIcebergQueryRunner(
ImmutableMap.of(),
ImmutableMap.of(),
PARQUET,
false,
true,
OptionalInt.of(1),
Optional.empty());
return IcebergQueryRunner.builder()
.setCatalogType(HIVE)
.setNodeCount(OptionalInt.of(1))
.build().getQueryRunner();
}
catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.facebook.presto.testing.QueryRunner;
import com.facebook.presto.testing.assertions.Assert;
import com.facebook.presto.tests.AbstractTestIntegrationSmokeTest;
import com.google.common.collect.ImmutableMap;
import org.apache.iceberg.Table;
import org.apache.iceberg.UpdateProperties;
import org.intellij.lang.annotations.Language;
Expand Down Expand Up @@ -74,7 +73,7 @@ protected IcebergDistributedSmokeTestBase(CatalogType catalogType)
protected QueryRunner createQueryRunner()
throws Exception
{
return IcebergQueryRunner.createIcebergQueryRunner(ImmutableMap.of(), catalogType);
return IcebergQueryRunner.builder().setCatalogType(catalogType).build().getQueryRunner();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,10 @@ protected IcebergDistributedTestBase(CatalogType catalogType)
protected QueryRunner createQueryRunner()
throws Exception
{
return IcebergQueryRunner.createIcebergQueryRunner(ImmutableMap.of(), catalogType, extraConnectorProperties);
return IcebergQueryRunner.builder()
.setCatalogType(catalogType)
.setExtraConnectorProperties(extraConnectorProperties)
.build().getQueryRunner();
}

@Test
Expand Down
Loading

0 comments on commit 686e6b3

Please sign in to comment.