use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowOnTwoGTComparisonsForSameBound.
@Test
public void shouldThrowOnTwoGTComparisonsForSameBound() {
// Given:
final Expression keyExp = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new IntegerLiteral(1));
final Expression windowStart = new ComparisonExpression(Type.GREATER_THAN, new UnqualifiedColumnReferenceExp(ColumnName.of("WINDOWSTART")), new IntegerLiteral(2));
final Expression windowEnd = new ComparisonExpression(Type.GREATER_THAN, new UnqualifiedColumnReferenceExp(ColumnName.of("WINDOWSTART")), new IntegerLiteral(3));
final Expression expressionA = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, keyExp, windowStart);
final Expression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, expressionA, windowEnd);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, true, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("Duplicate `WINDOWSTART` bounds on: GREATER_THAN"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldExtractConstraintForMultiKeyExpressionsThatDontCoverAllKeys_tableScan.
@Test
public void shouldExtractConstraintForMultiKeyExpressionsThatDontCoverAllKeys_tableScan() {
// Given:
when(plannerOptions.getTableScansEnabled()).thenReturn(true);
when(source.getSchema()).thenReturn(MULTI_KEY_SCHEMA);
final Expression expression = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K1")), new IntegerLiteral(1));
// Then:
expectTableScan(expression, false);
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowKeyExpressionThatDoestCoverKey.
@Test
public void shouldThrowKeyExpressionThatDoestCoverKey() {
// Given:
when(source.getSchema()).thenReturn(INPUT_SCHEMA);
final Expression expression = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("WINDOWSTART")), new IntegerLiteral(1234));
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, true, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("WHERE clause missing key column for disjunct: " + "(WINDOWSTART = 1234)"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowOnFailToParseTimestamp.
@Test
public void shouldThrowOnFailToParseTimestamp() {
// Given:
final Expression keyExp = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new IntegerLiteral(1));
final Expression windowStart = new ComparisonExpression(Type.GREATER_THAN, new UnqualifiedColumnReferenceExp(ColumnName.of("WINDOWSTART")), new StringLiteral("Foobar"));
final Expression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, keyExp, windowStart);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("Failed to parse timestamp 'Foobar'"));
}
use of io.confluent.ksql.execution.expression.tree.ComparisonExpression 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