use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldResolveArraySchemaWithMapping.
@Test
public void shouldResolveArraySchemaWithMapping() {
// Given:
final GenericType a = GenericType.of("A");
final ParamType array = ArrayType.of(a);
final ImmutableMap<GenericType, SqlType> mapping = ImmutableMap.of(a, SqlTypes.STRING);
// When:
final SqlType resolved = GenericsUtil.applyResolved(array, mapping);
// Then:
assertThat(resolved, is(SqlTypes.array(SqlTypes.STRING)));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldIdentifyMapGeneric.
@Test
public void shouldIdentifyMapGeneric() {
// Given:
final MapType a = MapType.of(GenericType.of("A"), GenericType.of("B"));
final SqlArgument instance = SqlArgument.of(SqlTypes.map(SqlTypes.DOUBLE, SqlTypes.BIGINT));
// When:
final Map<GenericType, SqlType> mapping = GenericsUtil.reserveGenerics(a, instance);
// Then:
assertThat(mapping, hasEntry(a.key(), SqlTypes.DOUBLE));
assertThat(mapping, hasEntry(a.value(), SqlTypes.BIGINT));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldFailResolveSchemaWithIncompleteMapping.
@Test(expected = KsqlException.class)
public void shouldFailResolveSchemaWithIncompleteMapping() {
// Given:
final GenericType a = GenericType.of("A");
final Map<GenericType, SqlType> mapping = ImmutableMap.of();
// When:
GenericsUtil.applyResolved(a, mapping);
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldNotMapGenericsForNonSqlLambdaResolved.
@Test
public void shouldNotMapGenericsForNonSqlLambdaResolved() {
// Given:
final GenericType typeA = GenericType.of("A");
final GenericType typeB = GenericType.of("B");
final GenericType typeC = GenericType.of("C");
final LambdaType a = LambdaType.of(ImmutableList.of(typeA, typeC), typeB);
final SqlArgument instance = SqlArgument.of(SqlLambda.of(2));
// When:
final Map<GenericType, SqlType> mapping = GenericsUtil.reserveGenerics(a, instance);
// Then:
// the map should be empty since the instance type was a SqlLambda without any types resolved
assertThat(mapping.size(), is(0));
}
use of io.confluent.ksql.schema.ksql.types.SqlType in project ksql by confluentinc.
the class GenericsUtilTest method shouldIdentifyGeneric.
@Test
public void shouldIdentifyGeneric() {
// Given:
final GenericType a = GenericType.of("A");
final SqlArgument instance = SqlArgument.of(SqlTypes.STRING);
// When:
final Map<GenericType, SqlType> mapping = GenericsUtil.reserveGenerics(a, instance);
// Then:
assertThat(mapping, hasEntry(a, SqlTypes.STRING));
}
Aggregations