use of io.trino.testing.QueryRunner in project trino by trinodb.
the class TestKafkaConnectorTest method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
testingKafka = closeAfterClass(TestingKafka.create());
rawFormatTopic = "test_raw_" + UUID.randomUUID().toString().replaceAll("-", "_");
headersTopic = "test_header_" + UUID.randomUUID().toString().replaceAll("-", "_");
Map<SchemaTableName, KafkaTopicDescription> extraTopicDescriptions = ImmutableMap.<SchemaTableName, KafkaTopicDescription>builder().put(new SchemaTableName("default", rawFormatTopic), createDescription(rawFormatTopic, "default", rawFormatTopic, createFieldGroup("raw", ImmutableList.of(createOneFieldDescription("bigint_long", BIGINT, "0", "LONG"), createOneFieldDescription("bigint_int", BIGINT, "8", "INT"), createOneFieldDescription("bigint_short", BIGINT, "12", "SHORT"), createOneFieldDescription("bigint_byte", BIGINT, "14", "BYTE"), createOneFieldDescription("double_double", DOUBLE, "15", "DOUBLE"), createOneFieldDescription("double_float", DOUBLE, "23", "FLOAT"), createOneFieldDescription("varchar_byte", createVarcharType(6), "27:33", "BYTE"), createOneFieldDescription("boolean_long", BOOLEAN, "33", "LONG"), createOneFieldDescription("boolean_int", BOOLEAN, "41", "INT"), createOneFieldDescription("boolean_short", BOOLEAN, "45", "SHORT"), createOneFieldDescription("boolean_byte", BOOLEAN, "47", "BYTE"))))).put(new SchemaTableName("default", headersTopic), new KafkaTopicDescription(headersTopic, Optional.empty(), headersTopic, Optional.empty(), Optional.empty())).putAll(createJsonDateTimeTestTopic()).put(TABLE_INSERT_NEGATIVE_DATE, createDescription(TABLE_INSERT_NEGATIVE_DATE, createOneFieldDescription("key", BIGINT), ImmutableList.of(createOneFieldDescription("dt", DATE, ISO8601.toString())))).put(TABLE_INSERT_CUSTOMER, createDescription(TABLE_INSERT_CUSTOMER, createOneFieldDescription("phone", createVarcharType(15)), ImmutableList.of(createOneFieldDescription("custkey", BIGINT), createOneFieldDescription("acctbal", DOUBLE)))).put(TABLE_INSERT_ARRAY, createDescription(TABLE_INSERT_ARRAY, createOneFieldDescription("a", new ArrayType(DOUBLE)), ImmutableList.of(createOneFieldDescription("b", new ArrayType(DOUBLE))))).put(TABLE_INSERT_UNICODE_1, createDescription(TABLE_INSERT_UNICODE_1, createOneFieldDescription("key", BIGINT), ImmutableList.of(createOneFieldDescription("test", createVarcharType(50))))).put(TABLE_INSERT_UNICODE_2, createDescription(TABLE_INSERT_UNICODE_2, createOneFieldDescription("key", BIGINT), ImmutableList.of(createOneFieldDescription("test", createVarcharType(50))))).put(TABLE_INSERT_UNICODE_3, createDescription(TABLE_INSERT_UNICODE_3, createOneFieldDescription("key", BIGINT), ImmutableList.of(createOneFieldDescription("test", createVarcharType(50))))).put(TABLE_INSERT_HIGHEST_UNICODE, createDescription(TABLE_INSERT_HIGHEST_UNICODE, createOneFieldDescription("key", BIGINT), ImmutableList.of(createOneFieldDescription("test", createVarcharType(50))))).buildOrThrow();
QueryRunner queryRunner = KafkaQueryRunner.builder(testingKafka).setTables(TpchTable.getTables()).setExtraTopicDescription(extraTopicDescriptions).build();
return queryRunner;
}
use of io.trino.testing.QueryRunner in project trino by trinodb.
the class TestMinimalFunctionality method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
testingKafka = closeAfterClass(TestingKafka.create());
topicName = "test_" + randomUUID().toString().replaceAll("-", "_");
QueryRunner queryRunner = KafkaQueryRunner.builder(testingKafka).setExtraTopicDescription(ImmutableMap.<SchemaTableName, KafkaTopicDescription>builder().put(createEmptyTopicDescription(topicName, new SchemaTableName("default", topicName))).buildOrThrow()).setExtraKafkaProperties(ImmutableMap.<String, String>builder().put("kafka.messages-per-split", "100").buildOrThrow()).build();
return queryRunner;
}
use of io.trino.testing.QueryRunner in project trino by trinodb.
the class TestQueryTracker method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
Session defaultSession = testSessionBuilder().setCatalog("mock").setSchema("default").setSystemProperty(QUERY_MAX_PLANNING_TIME, "2s").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession).build();
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
return ImmutableList.of(MockConnectorFactory.builder().withGetColumns(ignored -> ImmutableList.of(new ColumnMetadata("col", VARCHAR))).withApplyFilter((ignored1, ignored2, ignored3) -> freeze()).build());
}
});
queryRunner.createCatalog("mock", "mock");
return queryRunner;
}
use of io.trino.testing.QueryRunner in project trino by trinodb.
the class TestRefreshMaterializedView method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
Session session = testSessionBuilder().setCatalog("mock").setSchema("default").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).build();
queryRunner.installPlugin(new MockConnectorPlugin(MockConnectorFactory.builder().withListSchemaNames(connectionSession -> ImmutableList.of("default")).withGetColumns(schemaTableName -> ImmutableList.of(new ColumnMetadata("nationkey", BIGINT))).withGetTableHandle((connectorSession, tableName) -> new MockConnectorTableHandle(tableName)).withGetMaterializedViews((connectorSession, schemaTablePrefix) -> ImmutableMap.of(new SchemaTableName("default", "delegate_refresh_to_connector"), new ConnectorMaterializedViewDefinition("SELECT nationkey FROM mock.default.test_table", Optional.of(new CatalogSchemaTableName("mock", "default", "test_storage")), Optional.of("mock"), Optional.of("default"), ImmutableList.of(new ConnectorMaterializedViewDefinition.Column("nationkey", BIGINT.getTypeId())), Optional.empty(), Optional.of("alice"), ImmutableMap.of()))).withDelegateMaterializedViewRefreshToConnector((connectorSession, schemaTableName) -> true).withRefreshMaterializedView(((connectorSession, schemaTableName) -> {
startRefreshMaterializedView.set(null);
SettableFuture<Void> refreshMaterializedView = SettableFuture.create();
finishRefreshMaterializedView.addListener(() -> refreshMaterializedView.set(null), directExecutor());
addExceptionCallback(refreshMaterializedView, () -> refreshInterrupted.set(null));
return toCompletableFuture(refreshMaterializedView);
})).build()));
queryRunner.createCatalog("mock", "mock");
return queryRunner;
}
use of io.trino.testing.QueryRunner in project trino by trinodb.
the class TestSystemConnector method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
Session defaultSession = testSessionBuilder().setCatalog("mock").setSchema("default").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(defaultSession).enableBackupCoordinator().build();
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withGetViews((session, schemaTablePrefix) -> ImmutableMap.of()).withListTables((session, s) -> ImmutableList.of(SCHEMA_TABLE_NAME)).withGetColumns(tableName -> getColumns.apply(tableName)).build();
return ImmutableList.of(connectorFactory);
}
});
queryRunner.createCatalog("mock", "mock", ImmutableMap.of());
return queryRunner;
}
Aggregations