Search in sources :

Example 1 with NotExpression

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

the class ExpressionTypeManagerTest method shouldEvaluateBooleanSchemaForNotLikeExpression.

@Test
public void shouldEvaluateBooleanSchemaForNotLikeExpression() {
    final Expression expression = new NotExpression(new LikePredicate(COL1, new StringLiteral("%foo"), Optional.empty()));
    final SqlType exprType0 = expressionTypeManager.getExpressionSqlType(expression);
    assertThat(exprType0, is(SqlTypes.BOOLEAN));
}
Also used : StringLiteral(io.confluent.ksql.execution.expression.tree.StringLiteral) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) CreateMapExpression(io.confluent.ksql.execution.expression.tree.CreateMapExpression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) 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) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) LikePredicate(io.confluent.ksql.execution.expression.tree.LikePredicate) Test(org.junit.Test)

Example 2 with NotExpression

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

the class ExpressionTreeRewriterTest method shouldRewriteNotExpression.

@Test
public void shouldRewriteNotExpression() {
    // Given:
    final NotExpression parsed = parseExpression("NOT 1 < 2");
    when(processor.apply(parsed.getValue(), context)).thenReturn(expr1);
    // When:
    final Expression rewritten = expressionRewriter.rewrite(parsed, context);
    // Then:
    assertThat(rewritten, equalTo(new NotExpression(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) NotExpression(io.confluent.ksql.execution.expression.tree.NotExpression) Test(org.junit.Test)

Aggregations

ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)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 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)2 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)2 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)2 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)2 Test (org.junit.Test)2 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)1 LikePredicate (io.confluent.ksql.execution.expression.tree.LikePredicate)1 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)1 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)1 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)1