Search in sources :

Example 1 with ConnectorTableLayout

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());
}
Also used : ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) ConnectorOutputTableHandle(com.facebook.presto.spi.ConnectorOutputTableHandle) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) SchemaTableName(com.facebook.presto.spi.SchemaTableName) ConnectorTableMetadata(com.facebook.presto.spi.ConnectorTableMetadata) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 2 with ConnectorTableLayout

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()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 3 with ConnectorTableLayout

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));
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 4 with ConnectorTableLayout

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()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 5 with ConnectorTableLayout

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()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Aggregations

ConnectorTableLayout (com.facebook.presto.spi.ConnectorTableLayout)39 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)27 ColumnHandle (com.facebook.presto.spi.ColumnHandle)11 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)11 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)10 ConnectorSession (com.facebook.presto.spi.ConnectorSession)8 Test (org.testng.annotations.Test)8 SchemaTableName (com.facebook.presto.spi.SchemaTableName)7 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)6 TupleDomain (com.facebook.presto.common.predicate.TupleDomain)4 ConnectorSplitSource (com.facebook.presto.spi.ConnectorSplitSource)4 Set (java.util.Set)4 Domain (com.facebook.presto.common.predicate.Domain)3 HiveColumnHandle.bucketColumnHandle (com.facebook.presto.hive.HiveColumnHandle.bucketColumnHandle)3 Constraint (com.facebook.presto.spi.Constraint)3 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)2 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)2 ConnectorTableLayoutHandle (com.facebook.presto.spi.ConnectorTableLayoutHandle)2 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)2 ConnectorTablePartitioning (com.facebook.presto.spi.ConnectorTablePartitioning)2