Search in sources :

Example 16 with JoinInfo

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"));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) KsqlException(io.confluent.ksql.util.KsqlException) Test(org.junit.Test)

Example 17 with JoinInfo

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)));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Join(io.confluent.ksql.planner.JoinTree.Join) Leaf(io.confluent.ksql.planner.JoinTree.Leaf) Test(org.junit.Test)

Example 18 with JoinInfo

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));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Test(org.junit.Test)

Example 19 with JoinInfo

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"));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Test(org.junit.Test)

Aggregations

JoinInfo (io.confluent.ksql.analyzer.Analysis.JoinInfo)19 Test (org.junit.Test)18 Node (io.confluent.ksql.planner.JoinTree.Node)15 Leaf (io.confluent.ksql.planner.JoinTree.Leaf)4 Join (io.confluent.ksql.planner.JoinTree.Join)3 KsqlException (io.confluent.ksql.util.KsqlException)3 JoinNode (io.confluent.ksql.planner.plan.JoinNode)1