use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class LogicalPlanner method buildSourceNode.
private PlanNode buildSourceNode(final boolean isWindowed) {
if (!analysis.isJoin()) {
return buildNonJoinNode(analysis.getFrom(), isWindowed, ksqlConfig);
}
final List<JoinInfo> joinInfo = analysis.getJoin();
final JoinTree.Node tree = JoinTree.build(joinInfo);
if (tree instanceof JoinTree.Leaf) {
throw new IllegalStateException("Expected more than one source:" + analysis.getAllDataSources());
}
final JoinNode joinNode = buildJoin((Join) tree, "", isWindowed);
joinNode.resolveKeyFormats();
return joinNode;
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldThrowOnCircularJoin.
@Test
public void shouldThrowOnCircularJoin() {
// Given:
when(j1.getLeftSource()).thenReturn(a);
when(j1.getRightSource()).thenReturn(b);
when(j2.getLeftSource()).thenReturn(a);
when(j2.getRightSource()).thenReturn(b);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
// 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 shouldIncludeOnlyColFromFirstInViableKeyIfOverlap.
@Test
public void shouldIncludeOnlyColFromFirstInViableKeyIfOverlap() {
// 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(e1);
when(j2.getRightJoinExpression()).thenReturn(e2);
final List<JoinInfo> joins = ImmutableList.of(j1, j2);
final Node root = JoinTree.build(joins);
// When:
final List<?> keys = root.viableKeyColumns();
// Then:
assertThat(keys, contains(col2));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldComputeEquivalenceSetWithOverlap.
@Test
public void shouldComputeEquivalenceSetWithOverlap() {
// 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);
// When:
final Node root = JoinTree.build(joins);
// Then:
assertThat(root.joinEquivalenceSet(), containsInAnyOrder(e1, e2, e3));
}
use of io.confluent.ksql.analyzer.Analysis.JoinInfo in project ksql by confluentinc.
the class JoinTreeTest method shouldComputeViableKeysWithOverlap.
@Test
public void shouldComputeViableKeysWithOverlap() {
// 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(col1);
when(j2.getRightJoinExpression()).thenReturn(col3);
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, col2, col3));
}
Aggregations