Search in sources :

Example 1 with StreamFilter

use of io.confluent.ksql.execution.plan.StreamFilter in project ksql by confluentinc.

the class StepSchemaResolverTest method shouldResolveSchemaForStreamFilter.

@Test
public void shouldResolveSchemaForStreamFilter() {
    // Given:
    final StreamFilter<?> step = new StreamFilter<>(PROPERTIES, streamSource, mock(Expression.class));
    // When:
    final LogicalSchema result = resolver.resolve(step, SCHEMA);
    // Then:
    assertThat(result, is(SCHEMA));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) TumblingWindowExpression(io.confluent.ksql.execution.windows.TumblingWindowExpression) SelectExpression(io.confluent.ksql.execution.plan.SelectExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) StreamFilter(io.confluent.ksql.execution.plan.StreamFilter) Test(org.junit.Test)

Example 2 with StreamFilter

use of io.confluent.ksql.execution.plan.StreamFilter in project ksql by confluentinc.

the class SchemaKStreamTest method shouldRewriteTimeComparisonInFilter.

@Test
@SuppressWarnings("rawtypes")
public void shouldRewriteTimeComparisonInFilter() {
    // Given:
    final PlanNode logicalPlan = givenInitialKStreamOf("SELECT col0, col2, col3 FROM test1 " + "WHERE ROWTIME = '1984-01-01T00:00:00+00:00' EMIT CHANGES;");
    final FilterNode filterNode = (FilterNode) logicalPlan.getSources().get(0).getSources().get(0);
    // When:
    final SchemaKStream<?> filteredSchemaKStream = initialSchemaKStream.filter(filterNode.getPredicate(), childContextStacker);
    // Then:
    final StreamFilter step = (StreamFilter) filteredSchemaKStream.getSourceStep();
    assertThat(step.getFilterExpression(), equalTo(new ComparisonExpression(ComparisonExpression.Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("ROWTIME")), new LongLiteral(441763200000L))));
}
Also used : ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) PlanNode(io.confluent.ksql.planner.plan.PlanNode) LongLiteral(io.confluent.ksql.execution.expression.tree.LongLiteral) FilterNode(io.confluent.ksql.planner.plan.FilterNode) StreamFilter(io.confluent.ksql.execution.plan.StreamFilter) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Aggregations

StreamFilter (io.confluent.ksql.execution.plan.StreamFilter)2 Test (org.junit.Test)2 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)1 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)1 Expression (io.confluent.ksql.execution.expression.tree.Expression)1 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)1 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)1 SelectExpression (io.confluent.ksql.execution.plan.SelectExpression)1 TumblingWindowExpression (io.confluent.ksql.execution.windows.TumblingWindowExpression)1 FilterNode (io.confluent.ksql.planner.plan.FilterNode)1 PlanNode (io.confluent.ksql.planner.plan.PlanNode)1 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)1