use of io.confluent.ksql.execution.expression.tree.InPredicate in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowOnInAndComparisonExpression.
@Test
public void shouldThrowOnInAndComparisonExpression() {
// Given:
final Expression expression1 = new ComparisonExpression(Type.EQUAL, new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new IntegerLiteral(1));
final Expression expression2 = new InPredicate(new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new InListExpression(ImmutableList.of(new IntegerLiteral(1), new IntegerLiteral(2))));
final Expression expression = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, expression1, expression2);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("A comparison condition on the key column cannot be " + "combined with other comparisons"));
}
use of io.confluent.ksql.execution.expression.tree.InPredicate in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldExtractKeyValuesFromInExpression.
@Test
public void shouldExtractKeyValuesFromInExpression() {
// Given:
final Expression expression = new InPredicate(new UnqualifiedColumnReferenceExp(ColumnName.of("K")), new InListExpression(ImmutableList.of(new IntegerLiteral(1), new IntegerLiteral(2))));
QueryFilterNode filterNode = new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions);
// When:
final List<LookupConstraint> keys = filterNode.getLookupConstraints();
// Then:
assertThat(filterNode.isWindowed(), is(false));
assertThat(keys.size(), is(2));
final KeyConstraint keyConstraint0 = (KeyConstraint) keys.get(0);
assertThat(keyConstraint0.getKey(), is(GenericKey.genericKey(1)));
assertThat(keyConstraint0.getWindowBounds(), is(Optional.empty()));
final KeyConstraint keyConstraint1 = (KeyConstraint) keys.get(1);
assertThat(keyConstraint1.getKey(), is(GenericKey.genericKey(2)));
assertThat(keyConstraint1.getWindowBounds(), is(Optional.empty()));
}
Aggregations