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);
}
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);
}
}
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)));
}
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);
}
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)))));
}
Aggregations