use of io.trino.testing.LocalQueryRunner in project trino by trinodb.
the class TestShowQueries method init.
@BeforeAll
public void init() {
LocalQueryRunner queryRunner = LocalQueryRunner.create(testSessionBuilder().setCatalog("local").setSchema("default").build());
queryRunner.createCatalog("mock", MockConnectorFactory.builder().withGetColumns(schemaTableName -> ImmutableList.of(ColumnMetadata.builder().setName("colaa").setType(BIGINT).build(), ColumnMetadata.builder().setName("cola_").setType(BIGINT).build(), ColumnMetadata.builder().setName("colabc").setType(BIGINT).build())).withListSchemaNames(session -> ImmutableList.of("mockschema")).withListTables((session, schemaName) -> ImmutableList.of(new SchemaTableName("mockSchema", "mockTable"))).build(), ImmutableMap.of());
queryRunner.createCatalog("testing_catalog", "mock", ImmutableMap.of());
assertions = new QueryAssertions(queryRunner);
}
use of io.trino.testing.LocalQueryRunner 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.testing.LocalQueryRunner in project trino by trinodb.
the class TestPushDistinctLimitIntoTableScan method createLocalQueryRunner.
@Override
protected Optional<LocalQueryRunner> createLocalQueryRunner() {
Session defaultSession = TestingSession.testSessionBuilder().setCatalog(TEST_CATALOG.getCatalogName()).setSchema("tiny").build();
LocalQueryRunner queryRunner = LocalQueryRunner.create(defaultSession);
queryRunner.createCatalog(TEST_CATALOG.getCatalogName(), MockConnectorFactory.builder().withApplyAggregation((session, handle, aggregates, assignments, groupingSets) -> {
if (testApplyAggregation != null) {
return testApplyAggregation.apply(session, handle, aggregates, assignments, groupingSets);
}
return Optional.empty();
}).build(), Map.of());
return Optional.of(queryRunner);
}
use of io.trino.testing.LocalQueryRunner in project trino by trinodb.
the class TestPartialTopNWithPresortedInput method createLocalQueryRunner.
@Override
protected LocalQueryRunner createLocalQueryRunner() {
Session session = testSessionBuilder().setCatalog(MOCK_CATALOG).setSchema(TEST_SCHEMA).build();
LocalQueryRunner queryRunner = LocalQueryRunner.builder(session).build();
MockConnectorFactory mockFactory = MockConnectorFactory.builder().withGetTableProperties((connectorSession, handle) -> {
MockConnectorTableHandle tableHandle = (MockConnectorTableHandle) handle;
if (tableHandle.getTableName().equals(tableA)) {
return new ConnectorTableProperties(TupleDomain.all(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(new SortingProperty<>(columnHandleA, ASC_NULLS_FIRST)));
}
throw new IllegalArgumentException();
}).withGetColumns(schemaTableName -> {
if (schemaTableName.equals(tableA)) {
return ImmutableList.of(new ColumnMetadata(columnNameA, VARCHAR), new ColumnMetadata(columnNameB, VARCHAR));
}
throw new IllegalArgumentException();
}).build();
queryRunner.createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
return queryRunner;
}
use of io.trino.testing.LocalQueryRunner in project trino by trinodb.
the class TestPartialTopNWithPresortedInput method assertPlanWithValidation.
private void assertPlanWithValidation(@Language("SQL") String sql, PlanMatchPattern pattern) {
LocalQueryRunner queryRunner = getQueryRunner();
queryRunner.inTransaction(queryRunner.getDefaultSession(), transactionSession -> {
Plan actualPlan = queryRunner.createPlan(transactionSession, sql, OPTIMIZED_AND_VALIDATED, false, WarningCollector.NOOP);
PlanAssert.assertPlan(transactionSession, queryRunner.getMetadata(), queryRunner.getFunctionManager(), queryRunner.getStatsCalculator(), actualPlan, pattern);
PlannerContext plannerContext = queryRunner.getPlannerContext();
new ValidateLimitWithPresortedInput().validate(actualPlan.getRoot(), transactionSession, plannerContext, createTestingTypeAnalyzer(plannerContext), actualPlan.getTypes(), WarningCollector.NOOP);
return null;
});
}
Aggregations