use of io.trino.procedure.TestProcedure in project trino by trinodb.
the class TestMockConnector method createQueryRunner.
@Override
protected QueryRunner createQueryRunner() throws Exception {
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(testSessionBuilder().build()).build();
queryRunner.installPlugin(new TpchPlugin());
queryRunner.createCatalog("tpch", "tpch");
queryRunner.installPlugin(new MockConnectorPlugin(MockConnectorFactory.builder().withListSchemaNames(connectionSession -> ImmutableList.of("default")).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("default", "nation"))) {
return TPCH_NATION_SCHEMA;
}
return ImmutableList.of(new ColumnMetadata("nationkey", BIGINT));
}).withGetTableHandle((session, tableName) -> {
if (tableName.equals(new SchemaTableName("default", "new_table"))) {
return null;
}
return new MockConnectorTableHandle(tableName);
}).withGetMaterializedViewProperties(() -> ImmutableList.of(durationProperty("refresh_interval", "Time interval after which materialized view will be refreshed", null, false))).withGetMaterializedViews((session, schemaTablePrefix) -> ImmutableMap.of(new SchemaTableName("default", "test_materialized_view"), 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 Column("nationkey", BIGINT.getTypeId())), Optional.empty(), Optional.of("alice"), ImmutableMap.of()))).withData(schemaTableName -> {
if (schemaTableName.equals(new SchemaTableName("default", "nation"))) {
return TPCH_NATION_DATA;
}
throw new UnsupportedOperationException();
}).withProcedures(ImmutableSet.of(new TestProcedure().get())).withSchemaProperties(() -> ImmutableList.<PropertyMetadata<?>>builder().add(booleanProperty("boolean_schema_property", "description", false, false)).build()).withTableProperties(() -> ImmutableList.<PropertyMetadata<?>>builder().add(integerProperty("integer_table_property", "description", 0, false)).build()).build()));
queryRunner.createCatalog("mock", "mock");
return queryRunner;
}
Aggregations