use of io.trino.metadata.TableHandle in project trino by trinodb.
the class AbstractOperatorBenchmark method getColumnTypes.
protected final List<Type> getColumnTypes(String tableName, String... columnNames) {
checkState(session.getCatalog().isPresent(), "catalog not set");
checkState(session.getSchema().isPresent(), "schema not set");
// look up the table
Metadata metadata = localQueryRunner.getMetadata();
QualifiedObjectName qualifiedTableName = new QualifiedObjectName(session.getCatalog().get(), session.getSchema().get(), tableName);
TableHandle tableHandle = metadata.getTableHandle(session, qualifiedTableName).orElseThrow(() -> new IllegalArgumentException(format("Table '%s' does not exist", qualifiedTableName)));
Map<String, ColumnHandle> allColumnHandles = metadata.getColumnHandles(session, tableHandle);
return Arrays.stream(columnNames).map(allColumnHandles::get).map(columnHandle -> metadata.getColumnMetadata(session, tableHandle, columnHandle).getType()).collect(toImmutableList());
}
use of io.trino.metadata.TableHandle in project trino by trinodb.
the class MemoryLocalQueryRunner method dropTable.
public void dropTable(String tableName) {
Session session = localQueryRunner.getDefaultSession();
Metadata metadata = localQueryRunner.getMetadata();
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, QualifiedObjectName.valueOf(tableName));
assertTrue(tableHandle.isPresent(), "Table " + tableName + " does not exist");
metadata.dropTable(session, tableHandle.get());
}
use of io.trino.metadata.TableHandle 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