Search in sources :

Example 6 with Join

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

use of io.confluent.ksql.planner.JoinTree.Join 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)

Aggregations

JoinInfo (io.confluent.ksql.analyzer.Analysis.JoinInfo)7 Join (io.confluent.ksql.planner.JoinTree.Join)7 Leaf (io.confluent.ksql.planner.JoinTree.Leaf)7 Iterables (com.google.common.collect.Iterables)4 AggregateAnalysisResult (io.confluent.ksql.analyzer.AggregateAnalysisResult)4 AggregateAnalyzer (io.confluent.ksql.analyzer.AggregateAnalyzer)4 AliasedDataSource (io.confluent.ksql.analyzer.Analysis.AliasedDataSource)4 Into (io.confluent.ksql.analyzer.Analysis.Into)4 NewTopic (io.confluent.ksql.analyzer.Analysis.Into.NewTopic)4 FilterTypeValidator (io.confluent.ksql.analyzer.FilterTypeValidator)4 FilterType (io.confluent.ksql.analyzer.FilterTypeValidator.FilterType)4 ImmutableAnalysis (io.confluent.ksql.analyzer.ImmutableAnalysis)4 RewrittenAnalysis (io.confluent.ksql.analyzer.RewrittenAnalysis)4 ExpressionTreeRewriter (io.confluent.ksql.engine.rewrite.ExpressionTreeRewriter)4 Context (io.confluent.ksql.engine.rewrite.ExpressionTreeRewriter.Context)4 CodeGenRunner (io.confluent.ksql.execution.codegen.CodeGenRunner)4 KsqlTopic (io.confluent.ksql.execution.ddl.commands.KsqlTopic)4 ColumnReferenceExp (io.confluent.ksql.execution.expression.tree.ColumnReferenceExp)4 Expression (io.confluent.ksql.execution.expression.tree.Expression)4 FunctionCall (io.confluent.ksql.execution.expression.tree.FunctionCall)4