use of io.trino.spi.connector.ConnectorFactory 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.spi.connector.ConnectorFactory in project trino by trinodb.
the class TestErrorThrowableInQuery method createQueryRunner.
@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
Session session = testSessionBuilder().setSystemProperty("task_concurrency", "1").setCatalog("mock").setSchema("default").setClientInfo("{\"clientVersion\":\"testVersion\"}").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).build();
try {
queryRunner.installPlugin(new TpchPlugin());
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
SchemaTableName stackOverflowErrorTableName = new SchemaTableName("default", "stack_overflow_during_planning");
SchemaTableName classFormatErrorTableName = new SchemaTableName("default", "class_format_error_during_planning");
MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListTables((session, s) -> ImmutableList.of(stackOverflowErrorTableName)).withGetColumns(schemaTableName -> ImmutableList.of(new ColumnMetadata("test_varchar", createUnboundedVarcharType()), new ColumnMetadata("test_bigint", BIGINT))).withGetTableHandle((session, schemaTableName) -> new MockConnectorTableHandle(schemaTableName)).withApplyProjection((session, handle, projections, assignments) -> {
MockConnectorTableHandle mockTableHandle = (MockConnectorTableHandle) handle;
if (stackOverflowErrorTableName.equals(mockTableHandle.getTableName())) {
throw new StackOverflowError("We run out of stack!!!!!!!!!!!");
}
if (classFormatErrorTableName.equals(mockTableHandle.getTableName())) {
throw new ClassFormatError("Bad class format!!!!!!!!!!");
}
throw new TrinoException(NOT_FOUND, "Unknown table: " + mockTableHandle.getTableName());
}).build();
return ImmutableList.of(connectorFactory);
}
});
queryRunner.createCatalog("mock", "mock", ImmutableMap.of());
} catch (Exception e) {
queryRunner.close();
throw e;
}
return queryRunner;
}
use of io.trino.spi.connector.ConnectorFactory 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;
}
use of io.trino.spi.connector.ConnectorFactory in project trino by trinodb.
the class TestMetadataManager method setUp.
@BeforeClass
public void setUp() throws Exception {
queryRunner = TpchQueryRunnerBuilder.builder().build();
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
SchemaTableName viewTableName = new SchemaTableName("UPPER_CASE_SCHEMA", "test_view");
MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListSchemaNames(session -> ImmutableList.of("UPPER_CASE_SCHEMA")).withGetTableHandle((session, schemaTableName) -> {
if (schemaTableName.equals(viewTableName)) {
return null;
}
return new MockConnectorTableHandle(schemaTableName);
}).withListTables((session, schemaNameOrNull) -> ImmutableList.of(new SchemaTableName("UPPER_CASE_SCHEMA", "UPPER_CASE_TABLE"))).withGetViews((session, prefix) -> ImmutableMap.of(viewTableName, getConnectorViewDefinition())).build();
return ImmutableList.of(connectorFactory);
}
});
queryRunner.createCatalog("upper_case_schema_catalog", "mock");
metadataManager = (MetadataManager) queryRunner.getMetadata();
}
use of io.trino.spi.connector.ConnectorFactory in project TiBigData by tidb-incubator.
the class ConnectorsPluginTest method testCreateConnector.
@Test
public void testCreateConnector() {
Plugin plugin = new ConnectorsPlugin();
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
factory.create("tidb", ConfigUtils.getProperties(), new TestingConnectorContext());
}
Aggregations