use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldThrowOnSelfJoin.
@Test
public void shouldThrowOnSelfJoin() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(a);
final List<JoinInfo> joins = ImmutableList.of(j1);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> JoinTree.build(joins));
// Then:
assertThat(e.getMessage(), containsString("Cannot perform circular join"));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo 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()));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldComputeEquivalenceSetWithoutOverlap.
@Test
public void shouldComputeEquivalenceSetWithoutOverlap() {
// 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(e3);
when(j2.getRightJoinExpression()).thenReturn(e4);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root.joinEquivalenceSet(), containsInAnyOrder(e3, e4));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldIncludeOnlyColFromLastInViableKeyEvenWithoutOverlap.
@Test
public void shouldIncludeOnlyColFromLastInViableKeyEvenWithoutOverlap() {
// 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(col1);
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, contains(col1));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method handlesBasicTwoWayJoin.
@Test
public void handlesBasicTwoWayJoin() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
final List<JoinInfo> joins = ImmutableList.of(j1);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root, instanceOf(Join.class));
assertThat(((Join) root).getLeft(), is(new JoinTree.Leaf(a)));
assertThat(((Join) root).getRight(), is(new JoinTree.Leaf(b)));
assertThat(((Join) root).getInfo(), is(j1));
}
Aggregations