use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestCostCalculator method tableScan.
private TableScanNode tableScan(String id, List<VariableReferenceExpression> variables) {
ImmutableMap.Builder<VariableReferenceExpression, ColumnHandle> assignments = ImmutableMap.builder();
for (VariableReferenceExpression variable : variables) {
assignments.put(variable, new TpchColumnHandle("orderkey", BIGINT));
}
TpchTableHandle tableHandle = new TpchTableHandle("orders", 1.0);
return new TableScanNode(Optional.empty(), new PlanNodeId(id), new TableHandle(new ConnectorId("tpch"), tableHandle, TpchTransactionHandle.INSTANCE, Optional.of(new TpchTableLayoutHandle(tableHandle, TupleDomain.all()))), variables, assignments.build(), TupleDomain.all(), TupleDomain.all());
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestValidateStreamingAggregations method testValidateSuccessful.
@Test
public void testValidateSuccessful() {
validatePlan(p -> p.aggregation(a -> a.step(SINGLE).singleGroupingSet(p.variable("nationkey")).source(p.tableScan(nationTableHandle, ImmutableList.of(p.variable("nationkey", BIGINT)), ImmutableMap.of(p.variable("nationkey", BIGINT), new TpchColumnHandle("nationkey", BIGINT))))));
validatePlan(p -> p.aggregation(a -> a.step(SINGLE).singleGroupingSet(p.variable("unique"), p.variable("nationkey")).preGroupedVariables(p.variable("unique"), p.variable("nationkey")).source(p.assignUniqueId(p.variable("unique"), p.tableScan(nationTableHandle, ImmutableList.of(p.variable("nationkey", BIGINT)), ImmutableMap.of(p.variable("nationkey", BIGINT), new TpchColumnHandle("nationkey", BIGINT)))))));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestPickTableLayout method replaceWithExistsWhenNoLayoutExist.
@Test
public void replaceWithExistsWhenNoLayoutExist() {
ColumnHandle columnHandle = new TpchColumnHandle("nationkey", BIGINT);
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("nationkey", BIGINT);
return p.filter(p.rowExpression("nationkey = BIGINT '44'"), p.tableScan(nationTableHandle, ImmutableList.of(p.variable("nationkey", BIGINT)), ImmutableMap.of(p.variable("nationkey", BIGINT), columnHandle), TupleDomain.none(), TupleDomain.none()));
}).matches(values("A"));
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("nationkey");
return p.filter(p.rowExpression("nationkey = BIGINT '44'"), p.tableScan(nationTableHandle, ImmutableList.of(variable("nationkey", BIGINT)), ImmutableMap.of(variable("nationkey", BIGINT), columnHandle), TupleDomain.none(), TupleDomain.none()));
}).matches(values("A"));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestPickTableLayout method nonDeterministicPredicate.
@Test
public void nonDeterministicPredicate() {
Type orderStatusType = createVarcharType(1);
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("orderstatus", orderStatusType);
return p.filter(p.rowExpression("orderstatus = 'O' AND rand() = 0"), p.tableScan(ordersTableHandle, ImmutableList.of(p.variable("orderstatus", orderStatusType)), ImmutableMap.of(p.variable("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType))));
}).matches(filter("rand() = 0", constrainedTableScanWithTableLayout("orders", ImmutableMap.of("orderstatus", singleValue(orderStatusType, utf8Slice("O"))), ImmutableMap.of("orderstatus", "orderstatus"))));
tester().assertThat(pickTableLayout.pickTableLayoutForPredicate()).on(p -> {
p.variable("orderstatus", orderStatusType);
return p.filter(p.rowExpression("orderstatus = 'O' AND rand() = 0"), p.tableScan(ordersTableHandle, ImmutableList.of(variable("orderstatus", orderStatusType)), ImmutableMap.of(variable("orderstatus", orderStatusType), new TpchColumnHandle("orderstatus", orderStatusType))));
}).matches(filter("rand() = 0", constrainedTableScanWithTableLayout("orders", ImmutableMap.of("orderstatus", singleValue(orderStatusType, utf8Slice("O"))), ImmutableMap.of("orderstatus", "orderstatus"))));
}
use of com.facebook.presto.tpch.TpchColumnHandle in project presto by prestodb.
the class TestPruneIndexSourceColumns method buildProjectedIndexSource.
private static PlanNode buildProjectedIndexSource(PlanBuilder p, Predicate<VariableReferenceExpression> projectionFilter) {
VariableReferenceExpression orderkey = p.variable("orderkey", INTEGER);
VariableReferenceExpression custkey = p.variable("custkey", INTEGER);
VariableReferenceExpression totalprice = p.variable("totalprice", DOUBLE);
ColumnHandle orderkeyHandle = new TpchColumnHandle(orderkey.getName(), INTEGER);
ColumnHandle custkeyHandle = new TpchColumnHandle(custkey.getName(), INTEGER);
ColumnHandle totalpriceHandle = new TpchColumnHandle(totalprice.getName(), DOUBLE);
return p.project(identityAssignmentsAsSymbolReferences(ImmutableList.of(orderkey, custkey, totalprice).stream().filter(projectionFilter).collect(toImmutableList())), p.indexSource(new TableHandle(new ConnectorId("local"), new TpchTableHandle("orders", TINY_SCALE_FACTOR), TestingTransactionHandle.create(), Optional.empty()), ImmutableSet.of(orderkey, custkey), ImmutableList.of(orderkey, custkey, totalprice), ImmutableMap.of(orderkey, orderkeyHandle, custkey, custkeyHandle, totalprice, totalpriceHandle), TupleDomain.fromFixedValues(ImmutableMap.of(totalpriceHandle, asNull(DOUBLE)))));
}
Aggregations