Search in sources :

Example 16 with NullLiteral

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

the class InterpretedExpressionTest method shouldEvaluateIsNullPredicate.

@Test
public void shouldEvaluateIsNullPredicate() {
    // Given:
    final Expression expression1 = new IsNullPredicate(COL11);
    final Expression expression2 = new IsNullPredicate(new NullLiteral());
    // When:
    InterpretedExpression interpreter1 = interpreter(expression1);
    InterpretedExpression interpreter2 = interpreter(expression2);
    // Then:
    assertThat(interpreter1.evaluate(make(11, true)), is(false));
    assertThat(interpreter1.evaluate(make(11, null)), is(true));
    assertThat(interpreter2.evaluate(ROW), is(true));
}
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) IsNullPredicate(io.confluent.ksql.execution.expression.tree.IsNullPredicate) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) Test(org.junit.Test)

Example 17 with NullLiteral

use of io.confluent.ksql.execution.expression.tree.NullLiteral 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)

Example 18 with NullLiteral

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

the class GenericExpressionResolverTest method shouldResolveNullLiteral.

@Test
public void shouldResolveNullLiteral() {
    // Given:
    final SqlType type = SqlTypes.STRING;
    final Expression exp = new NullLiteral();
    // When:
    final Object o = new GenericExpressionResolver(type, FIELD_NAME, registry, config, "insert value", false).resolve(exp);
    // Then:
    assertThat(o, Matchers.nullValue());
}
Also used : CreateStructExpression(io.confluent.ksql.execution.expression.tree.CreateStructExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) NullLiteral(io.confluent.ksql.execution.expression.tree.NullLiteral) Test(org.junit.Test)

Aggregations

NullLiteral (io.confluent.ksql.execution.expression.tree.NullLiteral)18 Test (org.junit.Test)17 Expression (io.confluent.ksql.execution.expression.tree.Expression)13 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)9 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)8 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)8 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)7 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)7 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)7 KsqlException (io.confluent.ksql.util.KsqlException)7 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)6 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)5 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)5 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)5 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)5 LongLiteral (io.confluent.ksql.execution.expression.tree.LongLiteral)4 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)3 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)3 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)3 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)3