use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.
the class TestRowFilter method init.
@BeforeAll
public void init() {
LocalQueryRunner runner = LocalQueryRunner.builder(SESSION).build();
runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
ConnectorViewDefinition view = new ConnectorViewDefinition("SELECT nationkey, name FROM local.tiny.nation", Optional.empty(), Optional.empty(), ImmutableList.of(new ConnectorViewDefinition.ViewColumn("nationkey", BigintType.BIGINT.getTypeId()), new ConnectorViewDefinition.ViewColumn("name", VarcharType.createVarcharType(25).getTypeId())), Optional.empty(), Optional.of(VIEW_OWNER), false);
MockConnectorFactory mock = MockConnectorFactory.builder().withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
return TPCH_NATION_SCHEMA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_NATION_WITH_HIDDEN_COLUMN;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_WITH_OPTIONAL_COLUMN;
}
throw new UnsupportedOperationException();
}).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation"))) {
return TPCH_NATION_DATA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_hidden_column"))) {
return TPCH_WITH_HIDDEN_COLUMN_DATA;
}
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_DATA;
}
throw new UnsupportedOperationException();
}).build();
runner.createCatalog(MOCK_CATALOG, mock, ImmutableMap.of());
MockConnectorFactory mockMissingColumns = MockConnectorFactory.builder().withName("mockmissingcolumns").withGetViews((s, prefix) -> ImmutableMap.<SchemaTableName, ConnectorViewDefinition>builder().put(new SchemaTableName("default", "nation_view"), view).buildOrThrow()).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_WITH_OPTIONAL_COLUMN;
}
throw new UnsupportedOperationException();
}).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("tiny", "nation_with_optional_column"))) {
return TPCH_NATION_DATA;
}
throw new UnsupportedOperationException();
}).withAllowMissingColumnsOnInsert(true).build();
runner.createCatalog(MOCK_CATALOG_MISSING_COLUMNS, mockMissingColumns, ImmutableMap.of());
assertions = new QueryAssertions(runner);
accessControl = assertions.getQueryRunner().getAccessControl();
}
use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.
the class TestSubqueries method init.
@BeforeAll
public void init() {
Session session = testSessionBuilder().setCatalog(CATALOG).setSchema(TINY_SCHEMA_NAME).build();
LocalQueryRunner runner = LocalQueryRunner.builder(session).build();
runner.createCatalog(CATALOG, new TpchConnectorFactory(1), ImmutableMap.of());
assertions = new QueryAssertions(runner);
}
use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.
the class TestHiddenColumns method setUp.
@BeforeClass
public void setUp() {
runner = LocalQueryRunner.create(TEST_SESSION);
runner.createCatalog(TEST_SESSION.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
}
use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.
the class RuleTester method defaultRuleTester.
public static RuleTester defaultRuleTester(List<Plugin> plugins, Map<String, String> sessionProperties, Optional<Integer> nodeCountForStats) {
Session.SessionBuilder sessionBuilder = testSessionBuilder().setCatalog(CATALOG_ID).setSchema("tiny").setSystemProperty("task_concurrency", // these tests don't handle exchanges from local parallel
"1");
for (Map.Entry<String, String> entry : sessionProperties.entrySet()) {
sessionBuilder.setSystemProperty(entry.getKey(), entry.getValue());
}
Session session = sessionBuilder.build();
LocalQueryRunner queryRunner = nodeCountForStats.map(nodeCount -> LocalQueryRunner.builder(session).withNodeCountForStats(nodeCount).build()).orElseGet(() -> LocalQueryRunner.create(session));
queryRunner.createCatalog(session.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
plugins.forEach(queryRunner::installPlugin);
return new RuleTester(queryRunner);
}
use of io.trino.plugin.tpch.TpchConnectorFactory in project trino by trinodb.
the class BenchmarkQueryRunner method createLocalQueryRunner.
public static LocalQueryRunner createLocalQueryRunner(Map<String, String> extraSessionProperties) {
SessionBuilder sessionBuilder = testSessionBuilder().setCatalog("tpch").setSchema(TINY_SCHEMA_NAME);
extraSessionProperties.forEach(sessionBuilder::setSystemProperty);
Session session = sessionBuilder.build();
LocalQueryRunner localQueryRunner = LocalQueryRunner.create(session);
// add tpch
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
return localQueryRunner;
}
Aggregations