use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldIncludeOnlyColFromLastInViableKeyEvenWithoutOverlap.
@Test
public void shouldIncludeOnlyColFromLastInViableKeyEvenWithoutOverlap() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(a);
when(j2.getRightSource()).thenReturn(c);
when(j1.getLeftJoinExpression()).thenReturn(e1);
when(j1.getRightJoinExpression()).thenReturn(e2);
when(j2.getLeftJoinExpression()).thenReturn(col1);
when(j2.getRightJoinExpression()).thenReturn(e3);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
final Node root = JoinTree.build(joins);
// When:
final List<?> keys = root.viableKeyColumns();
// Then:
assertThat(keys, contains(col1));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method handlesBasicTwoWayJoin.
@Test
public void handlesBasicTwoWayJoin() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
final List<JoinInfo> joins = ImmutableList.of(j1);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root, instanceOf(Join.class));
assertThat(((Join) root).getLeft(), is(new JoinTree.Leaf(a)));
assertThat(((Join) root).getRight(), is(new JoinTree.Leaf(b)));
assertThat(((Join) root).getInfo(), is(j1));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method handlesLeftThreeWayJoin.
@Test
public void handlesLeftThreeWayJoin() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(a);
when(j2.getRightSource()).thenReturn(c);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root, instanceOf(Join.class));
assertThat(root, is(new Join(new Join(new Leaf(a), new Leaf(b), j1), new Leaf(c), j2)));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldIgnoreOuterJoinsWhenComputingEquivalenceSets.
@Test
public void shouldIgnoreOuterJoinsWhenComputingEquivalenceSets() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(a);
when(j2.getRightSource()).thenReturn(c);
when(j1.getType()).thenReturn(JoinType.OUTER);
when(j2.getLeftJoinExpression()).thenReturn(e1);
when(j2.getRightJoinExpression()).thenReturn(e3);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root.joinEquivalenceSet(), containsInAnyOrder(e1, e3));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldIgnoreOuterJoinsWhenComputingViableKeys.
@Test
public void shouldIgnoreOuterJoinsWhenComputingViableKeys() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(a);
when(j2.getRightSource()).thenReturn(c);
when(j1.getType()).thenReturn(JoinType.OUTER);
when(j2.getLeftJoinExpression()).thenReturn(col1);
when(j2.getRightJoinExpression()).thenReturn(col2);
final Node root = JoinTree.build(ImmutableList.of(j1, j2));
// When:
final List<?> keys = root.viableKeyColumns();
// Then:
assertThat(keys, contains(col1, col2));
}