use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.
the class TestMemoryMetadata method testReadTableBeforeCreationCompleted.
@Test
public void testReadTableBeforeCreationCompleted() {
assertNoTables();
SchemaTableName tableName = new SchemaTableName("default", "temp_table");
ConnectorOutputTableHandle table = metadata.beginCreateTable(SESSION, new ConnectorTableMetadata(tableName, ImmutableList.of(), ImmutableMap.of()), Optional.empty());
List<SchemaTableName> tableNames = metadata.listTables(SESSION, Optional.empty());
assertTrue(tableNames.size() == 1, "Expected exactly one table");
ConnectorTableHandle tableHandle = metadata.getTableHandle(SESSION, tableName);
List<ConnectorTableLayoutResult> tableLayouts = metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty());
assertTrue(tableLayouts.size() == 1, "Expected exactly one layout.");
ConnectorTableLayout tableLayout = tableLayouts.get(0).getTableLayout();
ConnectorTableLayoutHandle tableLayoutHandle = tableLayout.getHandle();
assertTrue(tableLayoutHandle instanceof MemoryTableLayoutHandle);
assertTrue(((MemoryTableLayoutHandle) tableLayoutHandle).getDataFragments().isEmpty(), "Data fragments should be empty");
metadata.finishCreateTable(SESSION, table, ImmutableList.of(), ImmutableList.of());
}
use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.
the class JdbcMetadata method getTableLayouts.
@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
JdbcTableHandle tableHandle = (JdbcTableHandle) table;
ConnectorTableLayout layout = new ConnectorTableLayout(new JdbcTableLayoutHandle(session.getSqlFunctionProperties(), tableHandle, constraint.getSummary(), Optional.empty()));
return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.
the class DeltaMetadata method getTableLayouts.
@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
DeltaTableHandle tableHandle = (DeltaTableHandle) table;
// Split the predicate into partition column predicate and other column predicates
// Only the partition column predicate is fully enforced. Other predicate is partially enforced (best effort).
List<TupleDomain<ColumnHandle>> predicate = splitPredicate(constraint.getSummary());
TupleDomain<ColumnHandle> unenforcedPredicate = predicate.get(1);
DeltaTableLayoutHandle newDeltaTableLayoutHandle = new DeltaTableLayoutHandle(tableHandle, constraint.getSummary().transform(DeltaColumnHandle.class::cast), Optional.of(constraint.getSummary().toString(session.getSqlFunctionProperties())));
ConnectorTableLayout newLayout = new ConnectorTableLayout(newDeltaTableLayoutHandle, Optional.empty(), constraint.getSummary(), Optional.empty(), Optional.empty(), Optional.empty(), ImmutableList.of(), Optional.empty());
return ImmutableList.of(new ConnectorTableLayoutResult(newLayout, unenforcedPredicate));
}
use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.
the class PrometheusMetadata method getTableLayouts.
@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
PrometheusTableHandle tableHandle = (PrometheusTableHandle) table;
ConnectorTableLayout layout = new ConnectorTableLayout(new PrometheusTableLayoutHandle(tableHandle, constraint.getSummary()));
return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.
the class RedisMetadata method getTableLayouts.
@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
RedisTableHandle tableHandle = convertTableHandle(table);
ConnectorTableLayout layout = new ConnectorTableLayout(new RedisTableLayoutHandle(tableHandle));
return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Aggregations