Search in sources :

Example 11 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class AbstractTestHiveClient method testGetPartitionSplitsBatchUnpartitioned.

@Test
public void testGetPartitionSplitsBatchUnpartitioned() {
    try (Transaction transaction = newTransaction()) {
        ConnectorMetadata metadata = transaction.getMetadata();
        ConnectorSession session = newSession();
        ConnectorTableHandle tableHandle = getTableHandle(metadata, tableUnpartitioned);
        ConnectorTableLayout tableLayout = getTableLayout(session, metadata, tableHandle, Constraint.alwaysTrue(), transaction);
        ConnectorSplitSource splitSource = splitManager.getSplits(transaction.getTransactionHandle(), session, tableLayout.getHandle(), SPLIT_SCHEDULING_CONTEXT);
        assertEquals(getSplitCount(splitSource), 1);
    }
}
Also used : ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) TestingConnectorSession(com.facebook.presto.testing.TestingConnectorSession) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 12 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class AbstractTestHiveClient method testGetPartitionNamesUnpartitioned.

@Test
public void testGetPartitionNamesUnpartitioned() {
    try (Transaction transaction = newTransaction()) {
        ConnectorMetadata metadata = transaction.getMetadata();
        ConnectorTableHandle tableHandle = getTableHandle(metadata, tableUnpartitioned);
        ConnectorTableLayout tableLayout = getTableLayout(newSession(), metadata, tableHandle, Constraint.alwaysTrue(), transaction);
        assertEquals(getAllPartitions(tableLayout.getHandle()).size(), 1);
        assertExpectedTableLayout(tableLayout, unpartitionedTableLayout);
    }
}
Also used : ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 13 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class AbstractTestHiveClient method testGetPartitionSplitsTableNotReadablePartition.

@Test
public void testGetPartitionSplitsTableNotReadablePartition() {
    try (Transaction transaction = newTransaction()) {
        ConnectorMetadata metadata = transaction.getMetadata();
        ConnectorSession session = newSession();
        ConnectorTableHandle tableHandle = getTableHandle(metadata, tableNotReadable);
        assertNotNull(tableHandle);
        ColumnHandle dsColumn = metadata.getColumnHandles(session, tableHandle).get("ds");
        assertNotNull(dsColumn);
        ConnectorTableLayout tableLayout = getTableLayout(session, metadata, tableHandle, Constraint.alwaysTrue(), transaction);
        try {
            getSplitCount(splitManager.getSplits(transaction.getTransactionHandle(), session, tableLayout.getHandle(), SPLIT_SCHEDULING_CONTEXT));
            fail("Expected HiveNotReadableException");
        } catch (HiveNotReadableException e) {
            assertThat(e).hasMessageMatching("Table '.*\\.presto_test_not_readable' is not readable: reason for not readable");
            assertEquals(e.getTableName(), tableNotReadable);
            assertEquals(e.getPartition(), Optional.empty());
        }
    }
    try (Transaction transaction = newTransaction()) {
        ConnectorMetadata metadata = transaction.getMetadata();
        ConnectorSession session = newSession(ImmutableMap.of(OFFLINE_DATA_DEBUG_MODE_ENABLED, true));
        ConnectorTableHandle tableHandle = getTableHandle(metadata, tableNotReadable);
        assertNotNull(tableHandle);
        ColumnHandle dsColumn = metadata.getColumnHandles(session, tableHandle).get("ds");
        assertNotNull(dsColumn);
        ConnectorTableLayout tableLayout = getTableLayout(session, metadata, tableHandle, Constraint.alwaysTrue(), transaction);
        getSplitCount(splitManager.getSplits(transaction.getTransactionHandle(), session, tableLayout.getHandle(), SPLIT_SCHEDULING_CONTEXT));
    }
}
Also used : HiveColumnHandle.bucketColumnHandle(com.facebook.presto.hive.HiveColumnHandle.bucketColumnHandle) ColumnHandle(com.facebook.presto.spi.ColumnHandle) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) TestingConnectorSession(com.facebook.presto.testing.TestingConnectorSession) ConnectorSession(com.facebook.presto.spi.ConnectorSession) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 14 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class BigQueryMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    log.debug("getTableMetadata(session=%s, table=%s, constraint=%s, desiredColumns=%s)", session, table, constraint, desiredColumns);
    BigQueryTableHandle bigQueryTableHandle = (BigQueryTableHandle) table;
    if (desiredColumns.isPresent()) {
        bigQueryTableHandle = bigQueryTableHandle.withProjectedColumns(ImmutableList.copyOf(desiredColumns.get()));
    }
    BigQueryTableLayoutHandle bigQueryTableLayoutHandle = new BigQueryTableLayoutHandle(bigQueryTableHandle);
    return ImmutableList.of(new ConnectorTableLayoutResult(new ConnectorTableLayout(bigQueryTableLayoutHandle), constraint.getSummary()));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout)

Example 15 with ConnectorTableLayout

use of com.facebook.presto.spi.ConnectorTableLayout in project presto by prestodb.

the class AccumuloMetadata method getTableLayouts.

@Override
public List<ConnectorTableLayoutResult> getTableLayouts(ConnectorSession session, ConnectorTableHandle table, Constraint<ColumnHandle> constraint, Optional<Set<ColumnHandle>> desiredColumns) {
    AccumuloTableHandle tableHandle = (AccumuloTableHandle) table;
    ConnectorTableLayout layout = new ConnectorTableLayout(new AccumuloTableLayoutHandle(tableHandle, constraint.getSummary()));
    return ImmutableList.of(new ConnectorTableLayoutResult(layout, constraint.getSummary()));
}
Also used : AccumuloTableLayoutHandle(com.facebook.presto.accumulo.model.AccumuloTableLayoutHandle) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorTableLayout(com.facebook.presto.spi.ConnectorTableLayout) AccumuloTableHandle(com.facebook.presto.accumulo.model.AccumuloTableHandle)

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