Search in sources :

Example 1 with TableHandle

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

the class TestPinotQueryBase method tableScan.

protected TableScanNode tableScan(PlanBuilder planBuilder, PinotTableHandle connectorTableHandle, Map<VariableReferenceExpression, PinotColumnHandle> columnHandles) {
    List<VariableReferenceExpression> variables = ImmutableList.copyOf(columnHandles.keySet());
    ImmutableMap.Builder<VariableReferenceExpression, ColumnHandle> assignments = ImmutableMap.builder();
    for (VariableReferenceExpression variable : columnHandles.keySet()) {
        assignments.put(variable, columnHandles.get(variable));
    }
    TableHandle tableHandle = new TableHandle(pinotConnectorId, connectorTableHandle, TestingTransactionHandle.create(), Optional.empty());
    return planBuilder.tableScan(tableHandle, variables, assignments.build());
}
Also used : ColumnHandle(com.facebook.presto.spi.ColumnHandle) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) TableHandle(com.facebook.presto.spi.TableHandle) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with TableHandle

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

the class TestMetadataManager method testGetTableStatisticsThrows.

@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetTableStatisticsThrows() {
    Session session = testSessionBuilder().setSystemProperty(IGNORE_STATS_CALCULATOR_FAILURES, "false").build();
    TableHandle tableHandle = new TableHandle(new ConnectorId("upper_case_schema_catalog"), new ConnectorTableHandle() {
    }, TestingTransactionHandle.create(), Optional.empty());
    TransactionBuilder.transaction(queryRunner.getTransactionManager(), queryRunner.getAccessControl()).execute(session, transactionSession -> {
        queryRunner.getMetadata().getCatalogHandle(transactionSession, "upper_case_schema_catalog");
        assertEquals(queryRunner.getMetadata().getTableStatistics(transactionSession, tableHandle, ImmutableList.of(), alwaysTrue()), TableStatistics.empty());
    });
}
Also used : ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) Session(com.facebook.presto.Session) ConnectorId(com.facebook.presto.spi.ConnectorId) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) Test(org.testng.annotations.Test)

Example 3 with TableHandle

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

the class MetadataManager method getTableHandleForStatisticsCollection.

@Override
public Optional<TableHandle> getTableHandleForStatisticsCollection(Session session, QualifiedObjectName table, Map<String, Object> analyzeProperties) {
    requireNonNull(table, "table is null");
    Optional<CatalogMetadata> catalog = getOptionalCatalogMetadata(session, table.getCatalogName());
    if (catalog.isPresent()) {
        CatalogMetadata catalogMetadata = catalog.get();
        ConnectorId connectorId = catalogMetadata.getConnectorId(session, table);
        ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
        ConnectorTableHandle tableHandle = metadata.getTableHandleForStatisticsCollection(session.toConnectorSession(connectorId), toSchemaTableName(table), analyzeProperties);
        if (tableHandle != null) {
            return Optional.of(new TableHandle(connectorId, tableHandle, catalogMetadata.getTransactionHandleFor(connectorId), Optional.empty()));
        }
    }
    return Optional.empty();
}
Also used : ConnectorOutputTableHandle(com.facebook.presto.spi.ConnectorOutputTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.spi.ConnectorId) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle)

Example 4 with TableHandle

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

the class MetadataManager method getAlternativeTableHandle.

@Override
public TableHandle getAlternativeTableHandle(Session session, TableHandle tableHandle, PartitioningHandle partitioningHandle) {
    checkArgument(partitioningHandle.getConnectorId().isPresent(), "Expect partitioning handle from connector, got system partitioning handle");
    ConnectorId connectorId = partitioningHandle.getConnectorId().get();
    checkArgument(connectorId.equals(tableHandle.getConnectorId()), "ConnectorId of tableLayoutHandle and partitioningHandle does not match");
    CatalogMetadata catalogMetadata = getCatalogMetadata(session, connectorId);
    ConnectorMetadata metadata = catalogMetadata.getMetadataFor(connectorId);
    ConnectorTableLayoutHandle newTableLayoutHandle = metadata.getAlternativeLayoutHandle(session.toConnectorSession(connectorId), tableHandle.getLayout().get(), partitioningHandle.getConnectorHandle());
    return new TableHandle(tableHandle.getConnectorId(), tableHandle.getConnectorHandle(), tableHandle.getTransaction(), Optional.of(newTableLayoutHandle));
}
Also used : ConnectorTableLayoutHandle(com.facebook.presto.spi.ConnectorTableLayoutHandle) ConnectorOutputTableHandle(com.facebook.presto.spi.ConnectorOutputTableHandle) TableHandle(com.facebook.presto.spi.TableHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) ConnectorInsertTableHandle(com.facebook.presto.spi.ConnectorInsertTableHandle) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.spi.ConnectorId)

Example 5 with TableHandle

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

the class TestRemoveUnsupportedDynamicFilters method setup.

@BeforeClass
public void setup() {
    metadata = getQueryRunner().getMetadata();
    logicalRowExpressions = new LogicalRowExpressions(new RowExpressionDeterminismEvaluator(metadata.getFunctionAndTypeManager()), new FunctionResolution(metadata.getFunctionAndTypeManager()), metadata.getFunctionAndTypeManager());
    builder = new PlanBuilder(getQueryRunner().getDefaultSession(), new PlanNodeIdAllocator(), metadata);
    ConnectorId connectorId = getCurrentConnectorId();
    TableHandle lineitemTableHandle = new TableHandle(connectorId, new TpchTableHandle("lineitem", 1.0), TestingTransactionHandle.create(), Optional.empty());
    lineitemOrderKeyVariable = builder.variable("LINEITEM_OK", BIGINT);
    lineitemTableScanNode = builder.tableScan(lineitemTableHandle, ImmutableList.of(lineitemOrderKeyVariable), ImmutableMap.of(lineitemOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
    TableHandle ordersTableHandle = new TableHandle(connectorId, new TpchTableHandle("orders", 1.0), TestingTransactionHandle.create(), Optional.empty());
    ordersOrderKeyVariable = builder.variable("ORDERS_OK", BIGINT);
    ordersTableScanNode = builder.tableScan(ordersTableHandle, ImmutableList.of(ordersOrderKeyVariable), ImmutableMap.of(ordersOrderKeyVariable, new TpchColumnHandle("orderkey", BIGINT)));
}
Also used : RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) PlanNodeIdAllocator(com.facebook.presto.spi.plan.PlanNodeIdAllocator) TpchColumnHandle(com.facebook.presto.tpch.TpchColumnHandle) LogicalRowExpressions(com.facebook.presto.expressions.LogicalRowExpressions) TableHandle(com.facebook.presto.spi.TableHandle) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) FunctionResolution(com.facebook.presto.sql.relational.FunctionResolution) PlanBuilder(com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder) ConnectorId(com.facebook.presto.spi.ConnectorId) TpchTableHandle(com.facebook.presto.tpch.TpchTableHandle) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

TableHandle (com.facebook.presto.spi.TableHandle)70 ConnectorId (com.facebook.presto.spi.ConnectorId)37 ColumnHandle (com.facebook.presto.spi.ColumnHandle)29 VariableReferenceExpression (com.facebook.presto.spi.relation.VariableReferenceExpression)22 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)21 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)21 ImmutableList (com.google.common.collect.ImmutableList)20 ImmutableMap (com.google.common.collect.ImmutableMap)19 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)18 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)16 Session (com.facebook.presto.Session)15 Type (com.facebook.presto.common.type.Type)15 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)15 Optional (java.util.Optional)15 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)14 TableScanNode (com.facebook.presto.spi.plan.TableScanNode)14 List (java.util.List)14 Metadata (com.facebook.presto.metadata.Metadata)13 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)13 ConnectorSession (com.facebook.presto.spi.ConnectorSession)13