use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestValidateAggregationsWithDefaultValues method testWithPartialAggregationBelowJoin.
@Test
public void testWithPartialAggregationBelowJoin() {
PlanNode root = builder.aggregation(af -> af.step(FINAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(builder.join(INNER, builder.exchange(e -> e.type(REPARTITION).scope(LOCAL).fixedHashDistributionParitioningScheme(ImmutableList.of(variable), ImmutableList.of(variable)).addInputsSet(variable).addSource(builder.aggregation(ap -> ap.step(PARTIAL).groupingSets(groupingSets(ImmutableList.of(variable), 2, ImmutableSet.of(0))).source(tableScanNode)))), builder.values())));
validatePlan(root, true);
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPhasedExecutionSchedule method createBroadcastJoinPlanFragment.
private static PlanFragment createBroadcastJoinPlanFragment(String name, PlanFragment buildFragment) {
VariableReferenceExpression variable = new VariableReferenceExpression(Optional.empty(), "column", BIGINT);
PlanNode tableScan = new TableScanNode(Optional.empty(), new PlanNodeId(name), new TableHandle(new ConnectorId("test"), new TestingTableHandle(), TestingTransactionHandle.create(), Optional.empty()), ImmutableList.of(variable), ImmutableMap.of(variable, new TestingColumnHandle("column")), TupleDomain.all(), TupleDomain.all());
RemoteSourceNode remote = new RemoteSourceNode(Optional.empty(), new PlanNodeId("build_id"), buildFragment.getId(), ImmutableList.of(), false, Optional.empty(), REPLICATE);
PlanNode join = new JoinNode(Optional.empty(), new PlanNodeId(name + "_id"), INNER, tableScan, remote, ImmutableList.of(), ImmutableList.<VariableReferenceExpression>builder().addAll(tableScan.getOutputVariables()).addAll(remote.getOutputVariables()).build(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.of(REPLICATED), ImmutableMap.of());
return createFragment(join);
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestPhasedExecutionSchedule method createTableScanPlanFragment.
private static PlanFragment createTableScanPlanFragment(String name) {
VariableReferenceExpression variable = new VariableReferenceExpression(Optional.empty(), "column", BIGINT);
PlanNode planNode = new TableScanNode(Optional.empty(), new PlanNodeId(name), new TableHandle(new ConnectorId("test"), new TestingTableHandle(), TestingTransactionHandle.create(), Optional.empty()), ImmutableList.of(variable), ImmutableMap.of(variable, new TestingColumnHandle("column")), TupleDomain.all(), TupleDomain.all());
return createFragment(planNode);
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestTypeValidator method setUp.
@BeforeClass
public void setUp() {
variableAllocator = new PlanVariableAllocator();
variableA = variableAllocator.newVariable("a", BIGINT);
variableB = variableAllocator.newVariable("b", INTEGER);
variableC = variableAllocator.newVariable("c", DOUBLE);
variableD = variableAllocator.newVariable("d", DATE);
// varchar(3), to test type only coercion
variableE = variableAllocator.newVariable("e", VarcharType.createVarcharType(3));
Map<VariableReferenceExpression, ColumnHandle> assignments = ImmutableMap.<VariableReferenceExpression, ColumnHandle>builder().put(variableA, new TestingColumnHandle("a")).put(variableB, new TestingColumnHandle("b")).put(variableC, new TestingColumnHandle("c")).put(variableD, new TestingColumnHandle("d")).put(variableE, new TestingColumnHandle("e")).build();
baseTableScan = new TableScanNode(Optional.empty(), newId(), TEST_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), TupleDomain.all());
}
use of com.facebook.presto.spi.plan.TableScanNode in project presto by prestodb.
the class TestEffectivePredicateExtractor method testTableScan.
@Test
public void testTableScan() {
// Effective predicate is True if there is no effective predicate
Map<VariableReferenceExpression, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(AV, BV, CV, DV)));
PlanNode node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), TupleDomain.all());
RowExpression effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, TRUE_CONSTANT);
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.none(), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, FALSE_CONSTANT);
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(AV), Domain.singleValue(BIGINT, 1L))), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(1L), AV)));
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE_WITH_LAYOUT, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.withColumnDomains(ImmutableMap.of(scanAssignments.get(AV), Domain.singleValue(BIGINT, 1L), scanAssignments.get(BV), Domain.singleValue(BIGINT, 2L))), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjuncts(equals(bigintLiteral(2L), BV), equals(bigintLiteral(1L), AV)));
node = new TableScanNode(Optional.empty(), newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments, TupleDomain.all(), TupleDomain.all());
effectivePredicate = effectivePredicateExtractor.extract(node);
assertEquals(effectivePredicate, TRUE_CONSTANT);
}
Aggregations