Search in sources :

Example 1 with FinalProjectNode

use of io.confluent.ksql.planner.plan.FinalProjectNode in project ksql by confluentinc.

the class LogicalPlannerTest method testLimitStreamPullQueryLogicalPlan.

@Test
public void testLimitStreamPullQueryLogicalPlan() {
    final String simpleQuery = "SELECT * FROM test1 LIMIT 3;";
    final PlanNode logicalPlan = buildLogicalPlan(simpleQuery);
    assertThat(logicalPlan, instanceOf(KsqlBareOutputNode.class));
    assertThat(logicalPlan.getNodeOutputType(), equalTo(DataSourceType.KSTREAM));
    final PlanNode finalProjectNode = logicalPlan.getSources().get(0);
    assertThat(finalProjectNode, instanceOf(FinalProjectNode.class));
    assertThat(finalProjectNode.getNodeOutputType(), equalTo(DataSourceType.KSTREAM));
    final PlanNode queryLimitNode = finalProjectNode.getSources().get(0);
    assertThat(queryLimitNode, instanceOf(QueryLimitNode.class));
    assertThat(((QueryLimitNode) queryLimitNode).getLimit(), equalTo(3));
    assertThat(queryLimitNode.getNodeOutputType(), equalTo(DataSourceType.KSTREAM));
    final PlanNode dataSourceNode = queryLimitNode.getSources().get(0);
    assertThat(dataSourceNode, instanceOf(DataSourceNode.class));
    assertThat(dataSourceNode.getNodeOutputType(), equalTo(DataSourceType.KSTREAM));
}
Also used : DataSourceNode(io.confluent.ksql.planner.plan.DataSourceNode) PlanNode(io.confluent.ksql.planner.plan.PlanNode) KsqlBareOutputNode(io.confluent.ksql.planner.plan.KsqlBareOutputNode) FinalProjectNode(io.confluent.ksql.planner.plan.FinalProjectNode) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryLimitNode(io.confluent.ksql.planner.plan.QueryLimitNode) Test(org.junit.Test)

Example 2 with FinalProjectNode

use of io.confluent.ksql.planner.plan.FinalProjectNode in project ksql by confluentinc.

the class LogicalPlannerTest method testLimitTableScanLogicalPlan.

@Test
public void testLimitTableScanLogicalPlan() {
    final String simpleQuery = "SELECT * FROM test2 LIMIT 3;";
    final PlanNode logicalPlan = buildLogicalPlan(simpleQuery);
    assertThat(logicalPlan, instanceOf(KsqlBareOutputNode.class));
    assertThat(logicalPlan.getNodeOutputType(), equalTo(DataSourceType.KTABLE));
    final PlanNode finalProjectNode = logicalPlan.getSources().get(0);
    assertThat(finalProjectNode, instanceOf(FinalProjectNode.class));
    assertThat(finalProjectNode.getNodeOutputType(), equalTo(DataSourceType.KTABLE));
    final PlanNode queryLimitNode = finalProjectNode.getSources().get(0);
    assertThat(queryLimitNode, instanceOf(QueryLimitNode.class));
    assertThat(((QueryLimitNode) queryLimitNode).getLimit(), equalTo(3));
    assertThat(queryLimitNode.getNodeOutputType(), equalTo(DataSourceType.KTABLE));
    final PlanNode dataSourceNode = queryLimitNode.getSources().get(0);
    assertThat(dataSourceNode, instanceOf(DataSourceNode.class));
    assertThat(dataSourceNode.getNodeOutputType(), equalTo(DataSourceType.KTABLE));
}
Also used : DataSourceNode(io.confluent.ksql.planner.plan.DataSourceNode) PlanNode(io.confluent.ksql.planner.plan.PlanNode) KsqlBareOutputNode(io.confluent.ksql.planner.plan.KsqlBareOutputNode) FinalProjectNode(io.confluent.ksql.planner.plan.FinalProjectNode) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryLimitNode(io.confluent.ksql.planner.plan.QueryLimitNode) Test(org.junit.Test)

Aggregations

DataSourceNode (io.confluent.ksql.planner.plan.DataSourceNode)2 FinalProjectNode (io.confluent.ksql.planner.plan.FinalProjectNode)2 KsqlBareOutputNode (io.confluent.ksql.planner.plan.KsqlBareOutputNode)2 PlanNode (io.confluent.ksql.planner.plan.PlanNode)2 QueryLimitNode (io.confluent.ksql.planner.plan.QueryLimitNode)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Test (org.junit.Test)2