Search in sources :

Example 1 with IsNotNullPredicate

use of io.confluent.ksql.execution.expression.tree.IsNotNullPredicate in project ksql by confluentinc.

the class ExpressionTreeRewriterTest method shouldRewriteIsNotNullPredicate.

@Test
public void shouldRewriteIsNotNullPredicate() {
    // Given:
    final IsNotNullPredicate parsed = parseExpression("col0 IS NOT NULL");
    when(processor.apply(parsed.getValue(), context)).thenReturn(expr1);
    // When:
    final Expression rewritten = expressionRewriter.rewrite(parsed, context);
    // Then:
    assertThat(rewritten, equalTo(new IsNotNullPredicate(parsed.getLocation(), expr1)));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) LogicalBinaryExpression(io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SimpleCaseExpression(io.confluent.ksql.execution.expression.tree.SimpleCaseExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) IsNotNullPredicate(io.confluent.ksql.execution.expression.tree.IsNotNullPredicate) Test(org.junit.Test)

Example 2 with IsNotNullPredicate

use of io.confluent.ksql.execution.expression.tree.IsNotNullPredicate in project ksql by confluentinc.

the class InterpretedExpressionTest method shouldEvaluateIsNotNullPredicate.

@Test
public void shouldEvaluateIsNotNullPredicate() {
    // Given:
    final Expression expression1 = new IsNotNullPredicate(COL11);
    final Expression expression2 = new IsNotNullPredicate(new NullLiteral());
    // When:
    InterpretedExpression interpreter1 = interpreter(expression1);
    InterpretedExpression interpreter2 = interpreter(expression2);
    // Then:
    assertThat(interpreter1.evaluate(make(11, true)), is(true));
    assertThat(interpreter1.evaluate(make(11, null)), is(false));
    assertThat(interpreter2.evaluate(ROW), is(false));
}
Also used : ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) LogicalBinaryExpression(io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) CreateArrayExpression(io.confluent.ksql.execution.expression.tree.CreateArrayExpression) CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) InListExpression(io.confluent.ksql.execution.expression.tree.InListExpression) ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) SearchedCaseExpression(io.confluent.ksql.execution.expression.tree.SearchedCaseExpression) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) IsNotNullPredicate(io.confluent.ksql.execution.expression.tree.IsNotNullPredicate) Test(org.junit.Test)

Aggregations

ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)2 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)2 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)2 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)2 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)2 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)2 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)2 Expression (io.confluent.ksql.execution.expression.tree.Expression)2 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)2 IsNotNullPredicate (io.confluent.ksql.execution.expression.tree.IsNotNullPredicate)2 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)2 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)2 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)2 Test (org.junit.Test)2 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)1 NullLiteral (io.confluent.ksql.execution.expression.tree.NullLiteral)1 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)1