use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldIdentifyArrayGeneric.
@Test
public void shouldIdentifyArrayGeneric() {
// Given:
final ArrayType a = ArrayType.of(GenericType.of("A"));
final SqlArgument instance = SqlArgument.of(SqlTypes.array(SqlTypes.STRING));
// When:
final Map<GenericType, SqlType> mapping = GenericsUtil.reserveGenerics(a, instance);
// Then:
assertThat(mapping, hasEntry(a.element(), SqlTypes.STRING));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class DecimalUtilTest method shouldGetSchemaFromDecimal2_0.
@Test
public void shouldGetSchemaFromDecimal2_0() {
// When:
final SqlType schema = DecimalUtil.fromValue(new BigDecimal("12."));
// Then:
assertThat(schema, is(SqlTypes.decimal(2, 0)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class DecimalUtilTest method shouldGetSchemaFromDecimal10_5.
@Test
public void shouldGetSchemaFromDecimal10_5() {
// When:
final SqlType schema = DecimalUtil.fromValue(new BigDecimal("12345.12345"));
// Then:
assertThat(schema, is(SqlTypes.decimal(10, 5)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class DecimalUtilTest method shouldGetSchemaFromDecimal4_3.
@Test
public void shouldGetSchemaFromDecimal4_3() {
// When:
final SqlType schema = DecimalUtil.fromValue(new BigDecimal("0.005"));
// Then:
assertThat(schema, is(SqlTypes.decimal(4, 3)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class DefaultSqlValueCoercerTest method coerce.
private static Optional<?> coerce(final DefaultSqlValueCoercer coercer, final SqlType from, final SqlType to, final Object value) {
// When:
final Optional<SqlType> coercedType = coercer.canCoerce(from, to);
final Result result = coercer.coerce(value, to);
// Then:
assertThat("canCoerce(" + from + "," + to + ")", coercedType, is(not(Optional.empty())));
assertThat("coerce(" + value + "," + to + ")", result, is(not(Result.failure())));
return result.value();
}
Aggregations