Search in sources :

Example 1 with JoinInfo

use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.

the class JoinTreeTest method shouldComputeEmptyViableKeysForOuterJoins.

@Test
public void shouldComputeEmptyViableKeysForOuterJoins() {
    // Given:
    when(j1.getLeftSource()).thenReturn(a);
    when(j1.getRightSource()).thenReturn(b);
    when(j1.getType()).thenReturn(JoinType.OUTER);
    final List<JoinInfo> joins = ImmutableList.of(j1);
    final Node root = JoinTree.build(joins);
    // When:
    final List<?> keys = root.viableKeyColumns();
    // Then:
    assertThat(keys, is(empty()));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Test(org.junit.Test)

Example 2 with JoinInfo

use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.

the class JoinTreeTest method handlesRightThreeWayJoin.

@Test
public void handlesRightThreeWayJoin() {
    // Given:
    when(j1.getLeftSource()).thenReturn(a);
    when(j1.getRightSource()).thenReturn(b);
    when(j2.getLeftSource()).thenReturn(c);
    when(j2.getRightSource()).thenReturn(a);
    when(j2.flip()).thenReturn(j2);
    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 3 with JoinInfo

use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.

the class JoinTreeTest method shouldIgnoreNonQualifiedColumnReferencesWhenComputingViableKeys.

@Test
public void shouldIgnoreNonQualifiedColumnReferencesWhenComputingViableKeys() {
    // 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);
    final Node root = JoinTree.build(joins);
    // When:
    final List<?> keys = root.viableKeyColumns();
    // Then:
    assertThat(keys, is(empty()));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Test(org.junit.Test)

Example 4 with JoinInfo

use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.

the class JoinTreeTest method shouldComputeEmptyEquivalenceSetForOuterJoins.

@Test
public void shouldComputeEmptyEquivalenceSetForOuterJoins() {
    // Given:
    when(j1.getLeftSource()).thenReturn(a);
    when(j1.getRightSource()).thenReturn(b);
    when(j1.getType()).thenReturn(JoinType.OUTER);
    final List<JoinInfo> joins = ImmutableList.of(j1);
    // When:
    final Node root = JoinTree.build(joins);
    // Then:
    assertThat(root.joinEquivalenceSet(), is(empty()));
}
Also used : JoinInfo(io.confluent.ksql.analyzer.Analysis.JoinInfo) Node(io.confluent.ksql.planner.JoinTree.Node) Test(org.junit.Test)

Example 5 with JoinInfo

use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.

the class JoinTreeTest method shouldComputeViableKeysWithoutOverlap.

@Test
public void shouldComputeViableKeysWithoutOverlap() {
    // 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(col3);
    when(j2.getRightJoinExpression()).thenReturn(col4);
    final List<JoinInfo> joins = ImmutableList.of(j1, j2);
    final Node root = JoinTree.build(joins);
    // When:
    final List<?> keys = root.viableKeyColumns();
    // Then:
    assertThat(keys, contains(col3, col4));
}
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