use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.
the class TestPushTopNIntoTableScan method testPushSingleTopNIntoTableScan.
@Test
public void testPushSingleTopNIntoTableScan() {
try (RuleTester ruleTester = defaultRuleTester()) {
MockConnectorTableHandle connectorHandle = new MockConnectorTableHandle(TEST_SCHEMA_TABLE);
// make the mock connector return a new connectorHandle
MockConnectorFactory.ApplyTopN applyTopN = (session, handle, topNCount, sortItems, tableAssignments) -> Optional.of(new TopNApplicationResult<>(connectorHandle, true, false));
MockConnectorFactory mockFactory = createMockFactory(assignments, Optional.of(applyTopN));
ruleTester.getQueryRunner().createCatalog(MOCK_CATALOG, mockFactory, ImmutableMap.of());
ruleTester.assertThat(new PushTopNIntoTableScan(ruleTester.getMetadata())).on(p -> {
Symbol dimension = p.symbol(dimensionName, VARCHAR);
Symbol metric = p.symbol(metricName, BIGINT);
return p.topN(1, ImmutableList.of(dimension), p.tableScan(TEST_TABLE_HANDLE, ImmutableList.of(dimension, metric), ImmutableMap.of(dimension, dimensionColumn, metric, metricColumn)));
}).withSession(MOCK_SESSION).matches(tableScan(connectorHandle::equals, TupleDomain.all(), new HashMap<>()));
}
}
use of io.trino.spi.type.VarcharType.VARCHAR in project trino by trinodb.
the class TestThriftProjectionPushdown method testDoesNotFire.
@Test
public void testDoesNotFire() {
PushProjectionIntoTableScan pushProjectionIntoTableScan = new PushProjectionIntoTableScan(tester().getPlannerContext(), tester().getTypeAnalyzer(), new ScalarStatsCalculator(tester().getPlannerContext(), tester().getTypeAnalyzer()));
String columnName = "orderstatus";
ColumnHandle columnHandle = new ThriftColumnHandle(columnName, VARCHAR, "", false);
ConnectorTableHandle tableWithColumns = new ThriftTableHandle(TINY_SCHEMA, "nation", TupleDomain.all(), Optional.of(ImmutableSet.of(columnHandle)));
tester().assertThat(pushProjectionIntoTableScan).on(p -> {
Symbol orderStatusSymbol = p.symbol(columnName, VARCHAR);
return p.project(Assignments.of(p.symbol("expr_2", VARCHAR), orderStatusSymbol.toSymbolReference()), p.tableScan(new TableHandle(new CatalogName(CATALOG), tableWithColumns, ThriftTransactionHandle.INSTANCE), ImmutableList.of(orderStatusSymbol), ImmutableMap.of(orderStatusSymbol, columnHandle)));
}).doesNotFire();
}
Aggregations