use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method outputsCorrectJoinTreeString.
@Test
public void outputsCorrectJoinTreeString() {
// 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.debugString(0), is("⋈\n" + "+--⋈\n" + " +--a\n" + " +--b\n" + "+--c"));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldIncludeOnlyColFromFirstInViableKeyIfOverlap.
@Test
public void shouldIncludeOnlyColFromFirstInViableKeyIfOverlap() {
// 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(col2);
when(j2.getLeftJoinExpression()).thenReturn(e1);
when(j2.getRightJoinExpression()).thenReturn(e2);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
final Node root = JoinTree.build(joins);
// When:
final List<?> keys = root.viableKeyColumns();
// Then:
assertThat(keys, contains(col2));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldComputeEquivalenceSetWithOverlap.
@Test
public void shouldComputeEquivalenceSetWithOverlap() {
// 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(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, e2, e3));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldComputeViableKeysWithOverlap.
@Test
public void shouldComputeViableKeysWithOverlap() {
// 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(col1);
when(j1.getRightJoinExpression()).thenReturn(col2);
when(j2.getLeftJoinExpression()).thenReturn(col1);
when(j2.getRightJoinExpression()).thenReturn(col3);
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, col2, col3));
}
use of io.confluent.ksql.planner.JoinTree.Node in project ksql by confluentinc.
the class JoinTreeTest method shouldNotIncludeOnlyColFromFirstInViableKeysIfNoOverlap.
@Test
public void shouldNotIncludeOnlyColFromFirstInViableKeysIfNoOverlap() {
// 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(col2);
when(j2.getLeftJoinExpression()).thenReturn(e2);
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, is(empty()));
}