use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowIfNotComparisonExpression.
@Test
public void shouldThrowIfNotComparisonExpression() {
// Given:
final Expression expression = new BooleanLiteral(true);
// When:
final KsqlException e = assertThrows(KsqlException.class, () -> new QueryFilterNode(NODE_ID, source, expression, metaStore, ksqlConfig, false, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("Unsupported expression in WHERE clause: true."));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class QueryFilterNodeTest method shouldThrowOnInvalidTimestampType.
@Test
public void shouldThrowOnInvalidTimestampType() {
// 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 BooleanLiteral(false));
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, true, plannerOptions));
// Then:
assertThat(e.getMessage(), containsString("Window bounds must resolve to an INT, BIGINT, or " + "STRING containing a datetime."));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class ImplicitlyCastResolverTest method shouldNotCastToDecimal.
@Test
public void shouldNotCastToDecimal() {
// Given
final List<Literal> fromLiterals = Arrays.asList(new BooleanLiteral("true"), new StringLiteral("10.2"), new DecimalLiteral(BigDecimal.valueOf(10.133)));
for (final Literal literal : fromLiterals) {
// When
final Expression expression = ImplicitlyCastResolver.resolve(literal, DECIMAL_5_2);
// Then
assertThat("Should not cast " + literal.getClass().getSimpleName() + " to " + DECIMAL_5_2, expression, instanceOf(literal.getClass()));
assertThat("Should not cast " + literal.getClass().getSimpleName() + " to " + DECIMAL_5_2, expression.equals(literal), is(true));
}
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class InterpretedExpressionTest method shouldEvaluateLogicalExpressions_or.
@Test
public void shouldEvaluateLogicalExpressions_or() {
// Given:
final Expression expression1 = new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR, COL11, new BooleanLiteral(true));
final Expression expression2 = new LogicalBinaryExpression(LogicalBinaryExpression.Type.OR, COL11, new BooleanLiteral(false));
// When:
InterpretedExpression interpreter1 = interpreter(expression1);
InterpretedExpression interpreter2 = interpreter(expression2);
// Then:
assertThat(interpreter1.evaluate(make(11, true)), is(true));
assertThat(interpreter1.evaluate(make(11, false)), is(true));
assertThat(interpreter2.evaluate(make(11, true)), is(true));
assertThat(interpreter2.evaluate(make(11, false)), is(false));
}
use of io.confluent.ksql.execution.expression.tree.BooleanLiteral in project ksql by confluentinc.
the class InterpretedExpressionTest method shouldEvaluateLogicalExpressions_and.
@Test
public void shouldEvaluateLogicalExpressions_and() {
// Given:
final Expression expression1 = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, COL11, new BooleanLiteral(true));
final Expression expression2 = new LogicalBinaryExpression(LogicalBinaryExpression.Type.AND, COL11, new BooleanLiteral(false));
// When:
InterpretedExpression interpreter1 = interpreter(expression1);
InterpretedExpression interpreter2 = interpreter(expression2);
// Then:
assertThat(interpreter1.evaluate(make(11, true)), is(true));
assertThat(interpreter1.evaluate(make(11, false)), is(false));
assertThat(interpreter2.evaluate(make(11, true)), is(false));
assertThat(interpreter2.evaluate(make(11, false)), is(false));
}
Aggregations