Search in sources :

Example 1 with BytesLiteral

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

the class InterpretedExpressionTest method shouldEvaluateCastToBytes.

@Test
public void shouldEvaluateCastToBytes() {
    // Given:
    final Expression cast1 = new Cast(new BytesLiteral(ByteBuffer.wrap(new byte[] { 123 })), new Type(SqlPrimitiveType.of("BYTES")));
    // When:
    InterpretedExpression interpreter1 = interpreter(cast1);
    // Then:
    assertThat(interpreter1.evaluate(ROW), is(ByteBuffer.wrap(new byte[] { 123 })));
}
Also used : Cast(io.confluent.ksql.execution.expression.tree.Cast) LambdaType(io.confluent.ksql.function.types.LambdaType) IntegerType(io.confluent.ksql.function.types.IntegerType) GenericType(io.confluent.ksql.function.types.GenericType) SqlPrimitiveType(io.confluent.ksql.schema.ksql.types.SqlPrimitiveType) IntervalUnitType(io.confluent.ksql.function.types.IntervalUnitType) Type(io.confluent.ksql.execution.expression.tree.Type) ArrayType(io.confluent.ksql.function.types.ArrayType) 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) BytesLiteral(io.confluent.ksql.execution.expression.tree.BytesLiteral) Test(org.junit.Test)

Example 2 with BytesLiteral

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

the class InterpretedExpressionTest method shouldEvaluateComparisons_bytes.

@Test
public void shouldEvaluateComparisons_bytes() {
    // Given:
    final Expression expression1 = new ComparisonExpression(ComparisonExpression.Type.GREATER_THAN, BYTESCOL, new BytesLiteral(ByteBuffer.wrap(new byte[] { 123 })));
    final Expression expression2 = new ComparisonExpression(ComparisonExpression.Type.LESS_THAN, BYTESCOL, new BytesLiteral(ByteBuffer.wrap(new byte[] { 123 })));
    // When:
    InterpretedExpression interpreter1 = interpreter(expression1);
    InterpretedExpression interpreter2 = interpreter(expression2);
    // Then:
    assertThat(interpreter1.evaluate(make(14, ByteBuffer.wrap(new byte[] { 123 }))), is(false));
    assertThat(interpreter2.evaluate(make(14, ByteBuffer.wrap(new byte[] { 110 }))), is(true));
}
Also used : ComparisonExpression(io.confluent.ksql.execution.expression.tree.ComparisonExpression) 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) BytesLiteral(io.confluent.ksql.execution.expression.tree.BytesLiteral) Test(org.junit.Test)

Aggregations

ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)2 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)2 BytesLiteral (io.confluent.ksql.execution.expression.tree.BytesLiteral)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 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 Cast (io.confluent.ksql.execution.expression.tree.Cast)1 Type (io.confluent.ksql.execution.expression.tree.Type)1 ArrayType (io.confluent.ksql.function.types.ArrayType)1 GenericType (io.confluent.ksql.function.types.GenericType)1 IntegerType (io.confluent.ksql.function.types.IntegerType)1 IntervalUnitType (io.confluent.ksql.function.types.IntervalUnitType)1