use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldThrowOnMissingSource.
@Test
public void shouldThrowOnMissingSource() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(c);
when(j2.getRightSource()).thenReturn(d);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> JoinTree.build(joins));
// Then:
assertThat(e.getMessage(), containsString("neither source in the join is the FROM source"));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo 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.analyzer.Analysis.JoinInfo 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.analyzer.Analysis.JoinInfo 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"));
}
Aggregations