Search in sources :

Example 16 with DereferenceExpression

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

the class PartitionByParamsFactoryTest method shouldBuildResultSchemaWhenPartitioningByMultipleFields.

@Test
public void shouldBuildResultSchemaWhenPartitioningByMultipleFields() {
    // Given:
    final List<Expression> partitionBy = ImmutableList.of(new UnqualifiedColumnReferenceExp(COL1), new DereferenceExpression(Optional.empty(), new UnqualifiedColumnReferenceExp(COL3), "someField"), new ArithmeticUnaryExpression(Optional.empty(), Sign.MINUS, new UnqualifiedColumnReferenceExp(COL1)));
    // When:
    final LogicalSchema resultSchema = PartitionByParamsFactory.buildSchema(SCHEMA, partitionBy, functionRegistry);
    // Then:
    assertThat(resultSchema, is(LogicalSchema.builder().keyColumn(COL1, SqlTypes.INTEGER).keyColumn(ColumnName.of("someField"), SqlTypes.BIGINT).keyColumn(ColumnName.of("KSQL_COL_0"), SqlTypes.INTEGER).valueColumn(COL1, SqlTypes.INTEGER).valueColumn(COL2, SqlTypes.INTEGER).valueColumn(COL3, COL3_TYPE).valueColumn(SystemColumns.ROWTIME_NAME, SqlTypes.BIGINT).valueColumn(COL0, SqlTypes.STRING).valueColumn(ColumnName.of("someField"), SqlTypes.BIGINT).valueColumn(ColumnName.of("KSQL_COL_0"), SqlTypes.INTEGER).build()));
}
Also used : DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticBinaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression) Expression(io.confluent.ksql.execution.expression.tree.Expression) DereferenceExpression(io.confluent.ksql.execution.expression.tree.DereferenceExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) ArithmeticUnaryExpression(io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression) LogicalSchema(io.confluent.ksql.schema.ksql.LogicalSchema) UnqualifiedColumnReferenceExp(io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp) Test(org.junit.Test)

Aggregations

DereferenceExpression (io.confluent.ksql.execution.expression.tree.DereferenceExpression)16 Test (org.junit.Test)16 ArithmeticBinaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticBinaryExpression)8 Expression (io.confluent.ksql.execution.expression.tree.Expression)8 UnqualifiedColumnReferenceExp (io.confluent.ksql.execution.expression.tree.UnqualifiedColumnReferenceExp)7 ComparisonExpression (io.confluent.ksql.execution.expression.tree.ComparisonExpression)6 CreateArrayExpression (io.confluent.ksql.execution.expression.tree.CreateArrayExpression)6 CreateMapExpression (io.confluent.ksql.execution.expression.tree.CreateMapExpression)6 CreateStructExpression (io.confluent.ksql.execution.expression.tree.CreateStructExpression)6 InListExpression (io.confluent.ksql.execution.expression.tree.InListExpression)6 SearchedCaseExpression (io.confluent.ksql.execution.expression.tree.SearchedCaseExpression)6 SubscriptExpression (io.confluent.ksql.execution.expression.tree.SubscriptExpression)6 LogicalSchema (io.confluent.ksql.schema.ksql.LogicalSchema)6 NotExpression (io.confluent.ksql.execution.expression.tree.NotExpression)5 SimpleCaseExpression (io.confluent.ksql.execution.expression.tree.SimpleCaseExpression)5 ColumnName (io.confluent.ksql.name.ColumnName)5 ArithmeticUnaryExpression (io.confluent.ksql.execution.expression.tree.ArithmeticUnaryExpression)4 IntegerLiteral (io.confluent.ksql.execution.expression.tree.IntegerLiteral)3 SqlType (io.confluent.ksql.schema.ksql.types.SqlType)3 LogicalBinaryExpression (io.confluent.ksql.execution.expression.tree.LogicalBinaryExpression)2