use of io.trino.plugin.thrift.ThriftTableHandle in project trino by trinodb.
the class TestThriftProjectionPushdown method testProjectionPushdown.
@Test
public void testProjectionPushdown() {
PushProjectionIntoTableScan pushProjectionIntoTableScan = new PushProjectionIntoTableScan(tester().getPlannerContext(), tester().getTypeAnalyzer(), new ScalarStatsCalculator(tester().getPlannerContext(), tester().getTypeAnalyzer()));
TableHandle inputTableHandle = NATION_TABLE;
String columnName = "orderstatus";
ColumnHandle columnHandle = new ThriftColumnHandle(columnName, VARCHAR, "", false);
ConnectorTableHandle projectedThriftHandle = 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(inputTableHandle, ImmutableList.of(orderStatusSymbol), ImmutableMap.of(orderStatusSymbol, columnHandle)));
}).withSession(SESSION).matches(project(ImmutableMap.of("expr_2", expression(new SymbolReference(columnName))), tableScan(projectedThriftHandle::equals, TupleDomain.all(), ImmutableMap.of(columnName, columnHandle::equals))));
}
use of io.trino.plugin.thrift.ThriftTableHandle 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();
}
use of io.trino.plugin.thrift.ThriftTableHandle in project trino by trinodb.
the class TestThriftProjectionPushdown method testPruneColumns.
@Test
public void testPruneColumns() {
PruneTableScanColumns rule = new PruneTableScanColumns(tester().getMetadata());
ThriftColumnHandle nationKeyColumn = new ThriftColumnHandle("nationKey", VARCHAR, "", false);
ThriftColumnHandle nameColumn = new ThriftColumnHandle("name", VARCHAR, "", false);
tester().assertThat(rule).on(p -> {
Symbol nationKey = p.symbol(nationKeyColumn.getColumnName(), VARCHAR);
Symbol name = p.symbol(nameColumn.getColumnName(), VARCHAR);
return p.project(Assignments.of(p.symbol("expr", VARCHAR), nationKey.toSymbolReference()), p.tableScan(NATION_TABLE, ImmutableList.of(nationKey, name), ImmutableMap.<Symbol, ColumnHandle>builder().put(nationKey, nationKeyColumn).put(name, nameColumn).buildOrThrow()));
}).withSession(SESSION).matches(project(ImmutableMap.of("expr", expression(new SymbolReference(nationKeyColumn.getColumnName()))), tableScan(new ThriftTableHandle(TINY_SCHEMA, "nation", TupleDomain.all(), Optional.of(ImmutableSet.of(nationKeyColumn)))::equals, TupleDomain.all(), ImmutableMap.of(nationKeyColumn.getColumnName(), nationKeyColumn::equals))));
}
Aggregations