use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestDynamicFiltersChecker 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)));
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestValidateStreamingAggregations method validatePlan.
private void validatePlan(Function<PlanBuilder, PlanNode> planProvider) {
PlanBuilder builder = new PlanBuilder(TEST_SESSION, idAllocator, metadata);
PlanNode planNode = planProvider.apply(builder);
TypeProvider types = builder.getTypes();
getQueryRunner().inTransaction(session -> {
// metadata.getCatalogHandle() registers the catalog for the transaction
session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
new ValidateStreamingAggregations().validate(planNode, session, metadata, sqlParser, types, WarningCollector.NOOP);
return null;
});
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestValidateAggregationsWithDefaultValues method setup.
@BeforeClass
public void setup() {
metadata = getQueryRunner().getMetadata();
builder = new PlanBuilder(TEST_SESSION, new PlanNodeIdAllocator(), metadata);
ConnectorId connectorId = getCurrentConnectorId();
TpchTableHandle nationTpchTableHandle = new TpchTableHandle("nation", 1.0);
TableHandle nationTableHandle = new TableHandle(connectorId, nationTpchTableHandle, TestingTransactionHandle.create(), Optional.of(new TpchTableLayoutHandle(nationTpchTableHandle, TupleDomain.all())));
TpchColumnHandle nationkeyColumnHandle = new TpchColumnHandle("nationkey", BIGINT);
variable = builder.variable("nationkey");
tableScanNode = builder.tableScan(nationTableHandle, ImmutableList.of(variable), ImmutableMap.of(variable, nationkeyColumnHandle));
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestValidateStreamingJoins method validatePlan.
private void validatePlan(Function<PlanBuilder, PlanNode> planProvider) {
PlanBuilder builder = new PlanBuilder(TEST_SESSION, idAllocator, metadata);
PlanNode planNode = planProvider.apply(builder);
TypeProvider types = builder.getTypes();
getQueryRunner().inTransaction(testSession, session -> {
session.getCatalog().ifPresent(catalog -> metadata.getCatalogHandle(session, catalog));
new ValidateStreamingJoins().validate(planNode, session, metadata, sqlParser, types, WarningCollector.NOOP);
return null;
});
}
use of com.facebook.presto.sql.planner.iterative.rule.test.PlanBuilder in project presto by prestodb.
the class TestPinotPlanOptimizer method testDateFieldCompareToTimestampLiteralPredicatePushdown.
@Test
public void testDateFieldCompareToTimestampLiteralPredicatePushdown() {
PlanBuilder planBuilder = createPlanBuilder(defaultSessionHolder);
FilterNode filter = filter(planBuilder, tableScan(planBuilder, pinotTable, regionId, city, fare, daysSinceEpoch), getRowExpression("dayssinceepoch < TIMESTAMP '2014-01-31 00:00:00 UTC'", defaultSessionHolder));
PlanNode originalPlan = limit(planBuilder, 50L, filter);
PlanNode optimized = getOptimizedPlan(planBuilder, originalPlan);
assertPlanMatch(optimized, PinotTableScanMatcher.match(pinotTable, Optional.of("SELECT regionId, city, fare, daysSinceEpoch FROM hybrid WHERE \\(dayssinceepoch < 16101\\) LIMIT 50"), Optional.of(false), originalPlan.getOutputVariables(), useSqlSyntax()), typeProvider);
}
Aggregations