use of io.confluent.ksql.planner.JoinTree.Node 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()));
}
use of io.confluent.ksql.planner.JoinTree.Node 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()));
}
use of io.confluent.ksql.planner.JoinTree.Node 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));
}
use of io.confluent.ksql.planner.JoinTree.Node 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()));
}
use of io.confluent.ksql.planner.JoinTree.Node 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)));
}