use of io.confluent.ksql.execution.expression.tree.Expression in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteArithmeticBinary.
@Test
public void shouldRewriteArithmeticBinary() {
// Given:
final ArithmeticBinaryExpression parsed = parseExpression("1 + 2");
when(processor.apply(parsed.getLeft(), context)).thenReturn(expr1);
when(processor.apply(parsed.getRight(), context)).thenReturn(expr2);
// When
final Expression rewritten = expressionRewriter.rewrite(parsed, context);
// Then:
assertThat(rewritten, equalTo(new ArithmeticBinaryExpression(parsed.getLocation(), parsed.getOperator(), expr1, expr2)));
}
use of io.confluent.ksql.execution.expression.tree.Expression in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteType.
@Test
public void shouldRewriteType() {
// Given:
final Type type = new Type(SqlPrimitiveType.of("INTEGER"));
// When:
final Expression rewritten = expressionRewriter.rewrite(type, context);
// Then:
assertThat(rewritten, is(type));
}
use of io.confluent.ksql.execution.expression.tree.Expression in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteIsNullPredicateUsingPlugin.
@Test
public void shouldRewriteIsNullPredicateUsingPlugin() {
// Given:
final Expression parsed = parseExpression("col0 IS NULL");
// When/Then:
shouldRewriteUsingPlugin(parsed);
}
use of io.confluent.ksql.execution.expression.tree.Expression in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteLikePredicate.
@Test
public void shouldRewriteLikePredicate() {
// Given:
final LikePredicate parsed = parseExpression("col1 LIKE '%foo%' ESCAPE '!'");
when(processor.apply(parsed.getValue(), context)).thenReturn(expr1);
when(processor.apply(parsed.getPattern(), context)).thenReturn(expr2);
// When:
final Expression rewritten = expressionRewriter.rewrite(parsed, context);
// Then:
assertThat(rewritten, equalTo(new LikePredicate(parsed.getLocation(), expr1, expr2, Optional.of('!'))));
}
use of io.confluent.ksql.execution.expression.tree.Expression in project ksql by confluentinc.
the class ExpressionTreeRewriterTest method shouldRewriteArithmeticBinaryUsingPlugin.
@Test
public void shouldRewriteArithmeticBinaryUsingPlugin() {
// Given:
final Expression parsed = parseExpression("1 + 2");
// When/Then:
shouldRewriteUsingPlugin(parsed);
}
Aggregations