use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldResolveTypeForAddBigintIntegerLiteral.
@Test
public void shouldResolveTypeForAddBigintIntegerLiteral() {
final Expression expression = new ArithmeticBinaryExpression(Operator.ADD, TestExpressions.COL0, literal(10));
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
assertThat(type, is(SqlTypes.BIGINT));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForCreateMapExpression.
@Test
public void shouldEvaluateTypeForCreateMapExpression() {
// Given:
Expression expression = new CreateMapExpression(ImmutableMap.of(COL3, new UnqualifiedColumnReferenceExp(COL0)));
// When:
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(type, is(SqlTypes.map(SqlTypes.DOUBLE, SqlTypes.BIGINT)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForArrayReferenceInStruct.
@Test
public void shouldEvaluateTypeForArrayReferenceInStruct() {
// Given:
final SqlStruct inner = SqlTypes.struct().field("IN0", SqlTypes.array(SqlTypes.INTEGER)).build();
final LogicalSchema schema = LogicalSchema.builder().keyColumn(SystemColumns.ROWKEY_NAME, SqlTypes.STRING).valueColumn(COL0, inner).build();
expressionTypeManager = new ExpressionTypeManager(schema, functionRegistry);
final Expression structRef = new DereferenceExpression(Optional.empty(), new UnqualifiedColumnReferenceExp(COL0), "IN0");
final Expression expression = new SubscriptExpression(structRef, new IntegerLiteral(1));
// When:
final SqlType result = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(result, is(SqlTypes.INTEGER));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class ExpressionTypeManagerTest method shouldEvaluateTypeForCreateArrayExpressionWithNull.
@Test
public void shouldEvaluateTypeForCreateArrayExpressionWithNull() {
// Given:
Expression expression = new CreateArrayExpression(ImmutableList.of(new UnqualifiedColumnReferenceExp(COL0), new NullLiteral()));
// When:
final SqlType type = expressionTypeManager.getExpressionSqlType(expression);
// Then:
assertThat(type, is(SqlTypes.array(SqlTypes.BIGINT)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class KsqlTypesSerdeModuleTest method shouldSerDeSqlArrayTypes.
@Test
public void shouldSerDeSqlArrayTypes() throws JsonProcessingException {
// Given:
final SqlType[] types = new SqlType[] { SqlTypes.INTEGER, SqlTypes.BIGINT, SqlTypes.DOUBLE, SqlTypes.STRING };
for (final SqlType type : types) {
// When:
final SqlType out = MAPPER.readValue(MAPPER.writeValueAsString(SqlArray.of(type)), SqlType.class);
// Then
assertThat(out, is(SqlArray.of(type)));
}
}
Aggregations