Skip to content

Commit

Permalink
Instantiate tpch connector using bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Jan 7, 2025
1 parent d2436a1 commit 63614b5
Show file tree
Hide file tree
Showing 35 changed files with 373 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.SessionTestUtils.TEST_SESSION;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.testing.MaterializedResult.resultBuilder;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -44,7 +43,7 @@ public void setUp()
{
runner = new StandaloneQueryRunner(TEST_SESSION);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
assertions = new QueryAssertions(runner);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.util.function.Function;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.spi.transaction.IsolationLevel.READ_UNCOMMITTED;
import static io.trino.testing.TestingSession.testSession;

Expand All @@ -38,7 +37,7 @@ public StatsCalculatorTester(Session session)
{
queryRunner = new StandaloneQueryRunner(session);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog(session.getCatalog().orElseThrow(), "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
queryRunner.createCatalog(session.getCatalog().orElseThrow(), "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
}

public StatsCalculatorAssertion assertStatsFor(Function<PlanBuilder, PlanNode> planProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.sql.planner.assertions.PlanMatchPattern.anyTree;
import static io.trino.sql.planner.assertions.PlanMatchPattern.node;
import static io.trino.testing.TestingHandles.TEST_CATALOG_NAME;
Expand All @@ -53,7 +52,7 @@ public void setUp()
queryRunner.createCatalog(
queryRunner.getDefaultSession().getCatalog().get(),
"tpch",
ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
ImmutableMap.of("tpch.splits-per-node", "1"));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
import static io.trino.execution.querystats.PlanOptimizersStatsCollector.createPlanOptimizersStatsCollector;
import static io.trino.execution.warnings.WarningCollector.NOOP;
import static io.trino.jmh.Benchmarks.benchmark;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_COLUMN_NAMING_PROPERTY;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.sql.planner.BenchmarkPlanner.Queries.TPCH;
import static io.trino.sql.planner.LogicalPlanner.Stage.OPTIMIZED;
Expand Down Expand Up @@ -103,8 +101,8 @@ public void setup()
planTester = PlanTester.create(session);
planTester.installPlugin(new TpchPlugin());
planTester.createCatalog(tpch, "tpch", ImmutableMap.<String, String>builder()
.put(TPCH_SPLITS_PER_NODE, "4")
.put(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.STANDARD.name())
.put("tpch.splits-per-node", "4")
.put("tpch.column-naming", ColumnNaming.STANDARD.name())
.buildOrThrow());

planTester.installPlugin(new MockConnectorPlugin(MockConnectorFactory.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.openjdk.jmh.runner.RunnerException;

import static io.trino.jmh.Benchmarks.benchmark;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.openjdk.jmh.annotations.Mode.AverageTime;
Expand Down Expand Up @@ -83,7 +82,7 @@ public void setup()
.build();
planTester = PlanTester.create(session);
planTester.installPlugin(new TpchPlugin());
planTester.createCatalog("tpch", "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
planTester.createCatalog("tpch", "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
}

public PlanTester getPlanTester()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import static com.google.common.base.Preconditions.checkState;
import static io.trino.jmh.Benchmarks.benchmark;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
Expand Down Expand Up @@ -83,7 +82,7 @@ public void setup()
.build();
queryRunner = new StandaloneQueryRunner(session);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
queryRunner.createCatalog("tpch", "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("EXPLAIN SELECT * FROM nation n1");
for (int i = 2; i <= numberOfTables; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

import static io.airlift.json.JsonCodec.jsonCodec;
import static io.trino.SessionTestUtils.TEST_SESSION;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCALE_FACTOR;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.predicate.Domain.all;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void setUp()
{
queryRunner = new StandaloneQueryRunner(TEST_SESSION);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
queryRunner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import static io.airlift.json.JsonCodec.mapJsonCodec;
import static io.trino.SessionTestUtils.TEST_SESSION;
import static io.trino.operator.RetryPolicy.NONE;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.type.BigintType.BIGINT;
import static io.trino.spi.type.IntegerType.INTEGER;
Expand Down Expand Up @@ -81,7 +80,7 @@ public void setUp()
// the expected values below simple non-distributed plans
queryRunner = new StandaloneQueryRunner(TEST_SESSION);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
queryRunner.createCatalog(TEST_SESSION.getCatalog().get(), "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import static io.trino.connector.MockConnectorEntities.TPCH_NATION_DATA;
import static io.trino.connector.MockConnectorEntities.TPCH_NATION_SCHEMA;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -58,7 +57,7 @@ public TestCheckConstraint()
QueryRunner runner = new StandaloneQueryRunner(SESSION);

runner.installPlugin(new TpchPlugin());
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

runner.installPlugin(new MockConnectorPlugin(MockConnectorFactory.builder()
.withGetColumns(schemaTableName -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@

import static io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_HIDDEN_COLUMN;
import static io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.type.IntegerType.INTEGER;
import static io.trino.testing.TestingAccessControlManager.TestingPrivilegeType.SELECT_COLUMN;
Expand Down Expand Up @@ -76,7 +75,7 @@ public TestColumnMask()
{
QueryRunner runner = new StandaloneQueryRunner(SESSION);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

ConnectorViewDefinition view = new ConnectorViewDefinition(
"SELECT nationkey, name FROM local.tiny.nation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.Map;

import static com.google.common.base.Preconditions.checkState;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.StandardErrorCode.FUNCTION_IMPLEMENTATION_ERROR;
import static io.trino.spi.StandardErrorCode.INVALID_FUNCTION_PROPERTY;
Expand Down Expand Up @@ -69,7 +68,7 @@ public TestInlineFunctions()

QueryRunner runner = new StandaloneQueryRunner(session);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
runner.installPlugin(new TestingLanguageEnginePlugin());

assertions = new QueryAssertions(runner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.testing.TestingSession.testSessionBuilder;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -43,7 +42,7 @@ public void test()

QueryRunner runner = new StandaloneQueryRunner(session);
runner.installPlugin(new TpchPlugin());
runner.createCatalog("local", "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog("local", "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

try (QueryAssertions assertions = new QueryAssertions(runner)) {
assertThat(assertions.query(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.testing.TestingHandles.TEST_CATALOG_NAME;
import static io.trino.testing.TestingSession.testSessionBuilder;
Expand All @@ -49,7 +48,7 @@ public TestNestedLogicalBinaryExpression()

QueryRunner runner = new StandaloneQueryRunner(session);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

assertions = new QueryAssertions(runner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import static io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_HIDDEN_COLUMN;
import static io.trino.connector.MockConnectorEntities.TPCH_NATION_WITH_OPTIONAL_COLUMN;
import static io.trino.connector.MockConnectorEntities.TPCH_WITH_HIDDEN_COLUMN_DATA;
import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.StandardErrorCode.COLUMN_NOT_FOUND;
import static io.trino.spi.StandardErrorCode.EXPRESSION_NOT_SCALAR;
Expand Down Expand Up @@ -78,7 +77,7 @@ public TestRowFilter()
{
QueryRunner runner = new StandaloneQueryRunner(SESSION);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(LOCAL_CATALOG, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

ConnectorViewDefinition view = new ConnectorViewDefinition(
"SELECT nationkey, name FROM local.tiny.nation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import java.util.List;
import java.util.Optional;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.type.DecimalType.createDecimalType;
import static io.trino.spi.type.IntegerType.INTEGER;
Expand Down Expand Up @@ -86,7 +85,7 @@ public TestSubqueries()

QueryRunner runner = new StandaloneQueryRunner(session);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

assertions = new QueryAssertions(runner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.testing.TestingHandles.TEST_CATALOG_NAME;
import static io.trino.testing.TestingSession.testSessionBuilder;
Expand All @@ -48,7 +47,7 @@ public TestWith()
QueryRunner runner = new StandaloneQueryRunner(session);

runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

assertions = new QueryAssertions(runner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.spi.StandardErrorCode.DIVISION_BY_ZERO;
import static io.trino.spi.StandardErrorCode.EXCEEDED_FUNCTION_MEMORY_LIMIT;
Expand Down Expand Up @@ -55,7 +54,7 @@ public void init()

QueryRunner runner = new StandaloneQueryRunner(session);
runner.installPlugin(new TpchPlugin());
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
runner.createCatalog(TEST_CATALOG_NAME, "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));
runner.installPlugin(new PythonFunctionsPlugin());

assertions = new QueryAssertions(runner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.trino.testing.StandaloneQueryRunner;
import org.junit.jupiter.api.Test;

import static io.trino.plugin.tpch.TpchConnectorFactory.TPCH_SPLITS_PER_NODE;
import static io.trino.plugin.tpch.TpchMetadata.TINY_SCHEMA_NAME;
import static io.trino.testing.TestingSession.testSessionBuilder;

Expand All @@ -38,7 +37,7 @@ protected QueryRunner createQueryRunner()

QueryRunner queryRunner = new StandaloneQueryRunner(defaultSession);
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog(defaultSession.getCatalog().get(), "tpch", ImmutableMap.of(TPCH_SPLITS_PER_NODE, "1"));
queryRunner.createCatalog(defaultSession.getCatalog().get(), "tpch", ImmutableMap.of("tpch.splits-per-node", "1"));

queryRunner.installPlugin(new MLPlugin());
return queryRunner;
Expand Down
34 changes: 30 additions & 4 deletions plugin/trino-tpch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,28 @@
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>bootstrap</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>configuration</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>json</artifactId>
</dependency>

<dependency>
Expand All @@ -38,6 +53,11 @@
<artifactId>tpch</artifactId>
</dependency>

<dependency>
<groupId>org.weakref</groupId>
<artifactId>jmxutils</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
Expand Down Expand Up @@ -74,6 +94,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jdk8</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>junit-extensions</artifactId>
Expand Down
Loading

0 comments on commit 63614b5

Please sign in to comment.