use of io.confluent.ksql.planner.plan.QueryFilterNode.WindowBounds in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldExtractKeyValueFromExpressionWithNoWindowBounds.
// We should refactor the WindowBounds class to encompass the functionality around
// extracting them from expressions instead of having them in WhereInfo
@Test
public void shouldExtractKeyValueFromExpressionWithNoWindowBounds() {
// Given:
final Expression expression = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new IntegerLiteral(1));
QueryFilterNode filterNode = new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, true, plannerOptions);
// When:
final List<LookupConstraint> keys = filterNode.getLookupConstraints();
// Then:
assertThat(filterNode.isWindowed(), is(true));
assertThat(keys.size(), is(1));
final KeyConstraint keyConstraint = (KeyConstraint) keys.get(0);
assertThat(keyConstraint.getKey(), is(GenericKey.genericKey(1)));
assertThat(keyConstraint.getWindowBounds(), is(Optional.of(new WindowBounds())));
}
use of io.confluent.ksql.planner.plan.QueryFilterNode.WindowBounds in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldExtractKeyValueAndWindowBoundsFromExpressionWithLTEWindowEnd.
@Test
public void shouldExtractKeyValueAndWindowBoundsFromExpressionWithLTEWindowEnd() {
// Given:
final Expression keyExp = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new IntegerLiteral(1));
final Expression windowStart = new ComparisonExpression(Type.LESS_THAN_OR_EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("WINDOWEND")), new IntegerLiteral(2));
final Expression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, keyExp, windowStart);
QueryFilterNode filterNode = new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, true, plannerOptions);
// When:
final List<LookupConstraint> keys = filterNode.getLookupConstraints();
// Then:
assertThat(filterNode.isWindowed(), is(true));
assertThat(keys.size(), is(1));
final KeyConstraint keyConstraint = (KeyConstraint) keys.get(0);
assertThat(keyConstraint.getKey(), is(GenericKey.genericKey(1)));
assertThat(keyConstraint.getWindowBounds(), is(Optional.of(new WindowBounds(new WindowRange(), new WindowRange(null, Range.upTo(Instant.ofEpochMilli(2), BoundType.CLOSED), null)))));
}
Aggregations