Search in sources :

Example 6 with FilterNode

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

the class SqlPredicateTest method testFilterBiggerExpression.

@Test
public void testFilterBiggerExpression() throws Exception {
    String selectQuery = "SELECT col0, col2, col3 FROM test1 WHERE col0 > 100 AND LEN(col2) = 5;";
    PlanNode logicalPlan = buildLogicalPlan(selectQuery);
    FilterNode filterNode = (FilterNode) logicalPlan.getSources().get(0).getSources().get(0);
    initialSchemaKStream = new SchemaKStream(logicalPlan.getTheSourceNode().getSchema(), kStream, ksqlStream.getKeyField(), new ArrayList<>(), SchemaKStream.Type.SOURCE, functionRegistry, new MockSchemaRegistryClient());
    SqlPredicate predicate = new SqlPredicate(filterNode.getPredicate(), initialSchemaKStream.getSchema(), false, functionRegistry);
    Assert.assertTrue(predicate.getFilterExpression().toString().equalsIgnoreCase("((TEST1.COL0 > 100) AND" + " (LEN(TEST1.COL2) = 5))"));
    Assert.assertTrue(predicate.getColumnIndexes().length == 3);
}
Also used : PlanNode(io.confluent.ksql.planner.plan.PlanNode) MockSchemaRegistryClient(io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient) FilterNode(io.confluent.ksql.planner.plan.FilterNode) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

FilterNode (io.confluent.ksql.planner.plan.FilterNode)6 PlanNode (io.confluent.ksql.planner.plan.PlanNode)6 Test (org.junit.Test)6 MockSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient)4 ArrayList (java.util.ArrayList)4 ProjectNode (io.confluent.ksql.planner.plan.ProjectNode)2 StructuredDataSourceNode (io.confluent.ksql.planner.plan.StructuredDataSourceNode)2 JoinNode (io.confluent.ksql.planner.plan.JoinNode)1