use of io.trino.sql.planner.plan.JoinNode.EquiJoinClause in project trino by trinodb.
the class TestPushLimitThroughOuterJoin method testLimitWithPreSortedInputsLeftJoin.
@Test
public void testLimitWithPreSortedInputsLeftJoin() {
tester().assertThat(new PushLimitThroughOuterJoin()).on(p -> {
Symbol leftKey = p.symbol("leftKey");
Symbol rightKey = p.symbol("rightKey");
return p.limit(1, false, ImmutableList.of(rightKey), p.join(LEFT, p.values(5, leftKey), p.values(5, rightKey), new EquiJoinClause(leftKey, rightKey)));
}).doesNotFire();
tester().assertThat(new PushLimitThroughOuterJoin()).on(p -> {
Symbol leftKey = p.symbol("leftKey");
Symbol rightKey = p.symbol("rightKey");
return p.limit(1, false, ImmutableList.of(leftKey), p.join(LEFT, p.values(5, leftKey), p.values(5, rightKey), new EquiJoinClause(leftKey, rightKey)));
}).matches(limit(1, ImmutableList.of(), false, ImmutableList.of("leftKey"), join(LEFT, ImmutableList.of(equiJoinClause("leftKey", "rightKey")), limit(1, ImmutableList.of(), true, ImmutableList.of("leftKey"), values("leftKey")), values("rightKey"))));
}
use of io.trino.sql.planner.plan.JoinNode.EquiJoinClause in project trino by trinodb.
the class TestPushAggregationThroughOuterJoin method testDoesNotFireWhenAggregationOnMultipleSymbolsDoesNotHaveSomeSymbols.
@Test
public void testDoesNotFireWhenAggregationOnMultipleSymbolsDoesNotHaveSomeSymbols() {
tester().assertThat(new PushAggregationThroughOuterJoin()).on(p -> p.aggregation(ab -> ab.source(p.join(LEFT, p.values(ImmutableList.of(p.symbol("COL1")), ImmutableList.of(expressions("10"))), p.values(ImmutableList.of(p.symbol("COL2"), p.symbol("COL3")), ImmutableList.of(expressions("20", "30"))), ImmutableList.of(new EquiJoinClause(new Symbol("COL1"), new Symbol("COL2"))), ImmutableList.of(new Symbol("COL1")), ImmutableList.of(new Symbol("COL2")), Optional.empty(), Optional.empty(), Optional.empty())).addAggregation(new Symbol("MIN_BY"), PlanBuilder.expression("min_by(COL2, COL1)"), ImmutableList.of(DOUBLE, DOUBLE)).singleGroupingSet(new Symbol("COL1")))).doesNotFire();
tester().assertThat(new PushAggregationThroughOuterJoin()).on(p -> p.aggregation(ab -> ab.source(p.join(LEFT, p.values(ImmutableList.of(p.symbol("COL1")), ImmutableList.of(expressions("10"))), p.values(ImmutableList.of(p.symbol("COL2"), p.symbol("COL3")), ImmutableList.of(expressions("20", "30"))), ImmutableList.of(new EquiJoinClause(new Symbol("COL1"), new Symbol("COL2"))), ImmutableList.of(new Symbol("COL1")), ImmutableList.of(new Symbol("COL2")), Optional.empty(), Optional.empty(), Optional.empty())).addAggregation(new Symbol("SUM"), PlanBuilder.expression("sum(COL2)"), ImmutableList.of(DOUBLE)).addAggregation(new Symbol("MIN_BY"), PlanBuilder.expression("min_by(COL2, COL3)"), ImmutableList.of(DOUBLE, DOUBLE)).addAggregation(new Symbol("MAX_BY"), PlanBuilder.expression("max_by(COL2, COL1)"), ImmutableList.of(DOUBLE, DOUBLE)).singleGroupingSet(new Symbol("COL1")))).doesNotFire();
}
use of io.trino.sql.planner.plan.JoinNode.EquiJoinClause in project trino by trinodb.
the class TestPushAggregationThroughOuterJoin method testDoesNotFireWhenNotDistinct.
@Test
public void testDoesNotFireWhenNotDistinct() {
tester().assertThat(new PushAggregationThroughOuterJoin()).on(p -> p.aggregation(ab -> ab.source(p.join(LEFT, p.values(ImmutableList.of(p.symbol("COL1")), ImmutableList.of(expressions("10"), expressions("11"))), p.values(new Symbol("COL2")), ImmutableList.of(new EquiJoinClause(new Symbol("COL1"), new Symbol("COL2"))), ImmutableList.of(p.symbol("COL1")), ImmutableList.of(p.symbol("COL2")), Optional.empty(), Optional.empty(), Optional.empty())).addAggregation(new Symbol("AVG"), PlanBuilder.expression("avg(COL2)"), ImmutableList.of(DOUBLE)).singleGroupingSet(new Symbol("COL1")))).doesNotFire();
// https://github.com/prestodb/presto/issues/10592
tester().assertThat(new PushAggregationThroughOuterJoin()).on(p -> p.aggregation(ab -> ab.source(p.join(LEFT, p.project(Assignments.builder().putIdentity(p.symbol("COL1", BIGINT)).build(), p.aggregation(builder -> builder.singleGroupingSet(p.symbol("COL1"), p.symbol("unused")).source(p.values(ImmutableList.of(p.symbol("COL1"), p.symbol("unused")), ImmutableList.of(expressions("10", "1"), expressions("10", "2")))))), p.values(p.symbol("COL2")), ImmutableList.of(new EquiJoinClause(p.symbol("COL1"), p.symbol("COL2"))), ImmutableList.of(p.symbol("COL1")), ImmutableList.of(p.symbol("COL2")), Optional.empty(), Optional.empty(), Optional.empty())).addAggregation(p.symbol("AVG", DOUBLE), PlanBuilder.expression("avg(COL2)"), ImmutableList.of(DOUBLE)).singleGroupingSet(p.symbol("COL1")))).doesNotFire();
}
Aggregations