Search in sources :

Example 11 with SubscriptExpression

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

the class ExpressionTypeManagerTest method shouldEvaluateTypeForStructDereferenceInArray.

@Test
public void shouldEvaluateTypeForStructDereferenceInArray() {
    // Given:
    final SqlStruct inner = SqlTypes.struct().field("IN0", SqlTypes.INTEGER).build();
    final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(COL0, SqlTypes.array(inner)).build();
    expressionTypeManager = new ExpressionTypeManager(schema, functionRegistry);
    final Expression expression = new DereferenceExpression(Optional.empty(), new SubscriptExpression(TestExpressions.COL0, new IntegerLiteral(1)), "IN0");
    // When:
    final SqlType result = expressionTypeManager.getExpressionSqlType(expression);
    // Then:
    assertThat(result, is(SqlTypes.INTEGER));
}
Also used : SqlStruct(io.confluent.ksql.schema.ksql.types.SqlStruct) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) 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) SubscriptExpression(io.confluent.ksql.execution.expression.tree.SubscriptExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) SqlType(io.confluent.ksql.schema.ksql.types.SqlType) IntegerLiteral(io.confluent.ksql.execution.expression.tree.IntegerLiteral) Test(org.junit.Test)

Aggregations

ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)11 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)11 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)11 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)11 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)11 Expression (io.confluent.ksql.execution.expression.tree.Expression)11 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)11 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)11 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)11 Test (org.junit.Test)11 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)10 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)7 StringLiteral (io.confluent.ksql.execution.expression.tree.StringLiteral)7 DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)6 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)4 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)3 SqlStruct (io.confluent.ksql.schema.ksql.types.SqlStruct)3 DoubleLiteral (io.confluent.ksql.execution.expression.tree.DoubleLiteral)2