use of io.confluent.ksql.execution.util.CoercionUtil.Result in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceArrayOfCompatibleLiterals.
@Test
public void shouldCoerceArrayOfCompatibleLiterals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new CreateArrayExpression(ImmutableList.of(new IntegerLiteral(10), new IntegerLiteral(289476))), new CreateArrayExpression(ImmutableList.of(new StringLiteral("123456789000"), new StringLiteral("22"), new StringLiteral("\t -100 \t"))));
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.array(SqlTypes.BIGINT))));
assertThat(result.expressions(), is(ImmutableList.of(cast(new CreateArrayExpression(ImmutableList.of(new IntegerLiteral(10), new IntegerLiteral(289476))), SqlTypes.array(SqlTypes.BIGINT)), cast(new CreateArrayExpression(ImmutableList.of(new StringLiteral("123456789000"), new StringLiteral("22"), new StringLiteral("\t -100 \t"))), SqlTypes.array(SqlTypes.BIGINT)))));
}
use of io.confluent.ksql.execution.util.CoercionUtil.Result in project ksql by confluentinc.
the class CoercionUtilTest method shouldCoerceStringNumericWithENotationToDecimals.
@Test
public void shouldCoerceStringNumericWithENotationToDecimals() {
// Given:
final ImmutableList<Expression> expressions = ImmutableList.of(new IntegerLiteral(10), new StringLiteral("1e3"));
// When:
final Result result = CoercionUtil.coerceUserList(expressions, typeManager);
// Then:
assertThat(result.commonType(), is(Optional.of(SqlTypes.decimal(10, 0))));
assertThat(result.expressions(), is(ImmutableList.of(new DecimalLiteral(new BigDecimal("10")), new DecimalLiteral(new BigDecimal("1000")))));
}
Aggregations