Search in sources :

Example 66 with ConnectorId

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

the class InMemoryTransactionManager method getCatalogMetadataForWrite.

@Override
public CatalogMetadata getCatalogMetadataForWrite(TransactionId transactionId, String catalogName) {
    TransactionMetadata transactionMetadata = getTransactionMetadata(transactionId);
    // there is no need to ask for a connector specific id since the overlay connectors are read only
    ConnectorId connectorId = transactionMetadata.getConnectorId(catalogName).orElseThrow(() -> new PrestoException(NOT_FOUND, "Catalog does not exist: " + catalogName));
    return getCatalogMetadataForWrite(transactionId, connectorId);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ConnectorId(com.facebook.presto.spi.ConnectorId)

Example 67 with ConnectorId

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

the class FunctionAssertions method compileScanFilterProject.

private static SourceOperatorFactory compileScanFilterProject(SqlFunctionProperties sqlFunctionProperties, Optional<RowExpression> filter, RowExpression projection, ExpressionCompiler compiler) {
    try {
        Supplier<CursorProcessor> cursorProcessor = compiler.compileCursorProcessor(sqlFunctionProperties, filter, ImmutableList.of(projection), SOURCE_ID);
        Supplier<PageProcessor> pageProcessor = compiler.compilePageProcessor(sqlFunctionProperties, filter, ImmutableList.of(projection));
        return new ScanFilterAndProjectOperator.ScanFilterAndProjectOperatorFactory(0, new PlanNodeId("test"), SOURCE_ID, PAGE_SOURCE_PROVIDER, cursorProcessor, pageProcessor, new TableHandle(new ConnectorId("test"), new ConnectorTableHandle() {
        }, new ConnectorTransactionHandle() {
        }, Optional.empty()), ImmutableList.of(), ImmutableList.of(projection.getType()), Optional.empty(), new DataSize(0, BYTE), 0);
    } catch (Throwable e) {
        if (e instanceof UncheckedExecutionException) {
            e = e.getCause();
        }
        throw new RuntimeException("Error compiling filter " + filter + ": " + e.getMessage(), e);
    }
}
Also used : CursorProcessor(com.facebook.presto.operator.project.CursorProcessor) UncheckedExecutionException(com.google.common.util.concurrent.UncheckedExecutionException) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) PageProcessor(com.facebook.presto.operator.project.PageProcessor) DataSize(io.airlift.units.DataSize) TableHandle(com.facebook.presto.spi.TableHandle) ConnectorTableHandle(com.facebook.presto.spi.ConnectorTableHandle) ConnectorId(com.facebook.presto.spi.ConnectorId)

Example 68 with ConnectorId

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

the class TestConnectorOptimization method testPushFilterToTableScan.

@Test
public void testPushFilterToTableScan() {
    RowExpression expectedPredicate = and(newBigintVariable("a"), newBigintVariable("b"));
    PlanNode plan = output(filter(tableScan("cat1", "a", "b"), expectedPredicate), "a");
    PlanNode actual = optimize(plan, ImmutableMap.of(new ConnectorId("cat1"), ImmutableSet.of(filterPushdown())));
    // assert structure; FilterNode is removed
    assertPlanMatch(actual, PlanMatchPattern.output(SimpleTableScanMatcher.tableScan("cat1", expectedPredicate)));
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) RowExpression(com.facebook.presto.spi.relation.RowExpression) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Example 69 with ConnectorId

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

the class TestConnectorOptimization method testMultipleConnectors.

@Test
public void testMultipleConnectors() {
    PlanNode plan = output(union(tableScan("cat1", "a", "b"), tableScan("cat2", "a", "b"), tableScan("cat3", "a", "b"), tableScan("cat4", "a", "b"), tableScan("cat2", "a", "b"), tableScan("cat1", "a", "b"), values("a", "b")), "a");
    PlanNode actual = optimize(plan, ImmutableMap.of());
    assertEquals(actual, plan);
    actual = optimize(plan, ImmutableMap.of(new ConnectorId("cat2"), ImmutableSet.of(noop())));
    assertEquals(actual, plan);
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Example 70 with ConnectorId

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

the class TestConnectorOptimization method testPlanUpdateWithComplexStructures.

@Test
public void testPlanUpdateWithComplexStructures() {
    PlanNode plan = output(union(filter(tableScan("cat1", "a", "b"), TRUE_CONSTANT), filter(tableScan("cat2", "a", "b"), TRUE_CONSTANT), union(filter(tableScan("cat3", "a", "b"), TRUE_CONSTANT), union(filter(tableScan("cat4", "a", "b"), TRUE_CONSTANT), filter(tableScan("cat1", "a", "b"), TRUE_CONSTANT))), filter(tableScan("cat2", "a", "b"), TRUE_CONSTANT), union(filter(tableScan("cat1", "a", "b"), TRUE_CONSTANT))), "a");
    PlanNode actual = optimize(plan, ImmutableMap.of());
    assertEquals(actual, plan);
    // force updating every leaf node
    actual = optimize(plan, ImmutableMap.of(new ConnectorId("cat1"), ImmutableSet.of(filterPushdown()), new ConnectorId("cat2"), ImmutableSet.of(filterPushdown()), new ConnectorId("cat3"), ImmutableSet.of(filterPushdown()), new ConnectorId("cat4"), ImmutableSet.of(filterPushdown())));
    // assert all filters removed
    assertPlanMatch(actual, PlanMatchPattern.output(PlanMatchPattern.union(SimpleTableScanMatcher.tableScan("cat1", TRUE_CONSTANT), SimpleTableScanMatcher.tableScan("cat2", TRUE_CONSTANT), PlanMatchPattern.union(SimpleTableScanMatcher.tableScan("cat3", TRUE_CONSTANT), PlanMatchPattern.union(SimpleTableScanMatcher.tableScan("cat4", TRUE_CONSTANT), SimpleTableScanMatcher.tableScan("cat1", TRUE_CONSTANT))), SimpleTableScanMatcher.tableScan("cat2", TRUE_CONSTANT), PlanMatchPattern.union(SimpleTableScanMatcher.tableScan("cat1", TRUE_CONSTANT)))));
}
Also used : PlanNode(com.facebook.presto.spi.plan.PlanNode) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Aggregations

ConnectorId (com.facebook.presto.spi.ConnectorId)162 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)75 TableHandle (com.facebook.presto.spi.TableHandle)33 Test (org.testng.annotations.Test)29 ConnectorSession (com.facebook.presto.spi.ConnectorSession)26 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)18 PrestoException (com.facebook.presto.spi.PrestoException)18 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)18 Session (com.facebook.presto.Session)16 ImmutableList (com.google.common.collect.ImmutableList)16 QualifiedObjectName (com.facebook.presto.common.QualifiedObjectName)15 List (java.util.List)15 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)14 Map (java.util.Map)12 Optional (java.util.Optional)12 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)11 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)11 SchemaTableName (com.facebook.presto.spi.SchemaTableName)11 ImmutableMap (com.google.common.collect.ImmutableMap)11 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)10