use of io.confluent.ksql.function.types.ParamType 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.function.types.ParamType in project ksql by confluentinc.
the class GenericsUtilTest method shouldFindAllConstituentGenerics.
@Test
public void shouldFindAllConstituentGenerics() {
// Given:
final GenericType a = GenericType.of("A");
final GenericType b = GenericType.of("B");
final GenericType c = GenericType.of("C");
final GenericType d = GenericType.of("D");
final ParamType map = MapType.of(GenericType.of("C"), GenericType.of("D"));
final StructType complexSchema = StructType.builder().field("a", a).field("b", b).field("c", map).build();
// When:
final Set<ParamType> generics = GenericsUtil.constituentGenerics(complexSchema);
// Then:
assertThat(generics, containsInAnyOrder(a, b, c, d));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class GenericsUtilTest method shouldNotIdentifyGenericIncorrectly.
@Test
public void shouldNotIdentifyGenericIncorrectly() {
// Given:
final ParamType array = ArrayType.of(GenericType.of("T"));
// Then:
assertThat("should not be a generic", !GenericsUtil.isGeneric(array));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class SchemaConvertersTest method shouldGetSqlTypeForAllParamTypes.
@Test
public void shouldGetSqlTypeForAllParamTypes() {
for (Entry<ParamType, SqlType> entry : SQL_TO_FUNCTION.inverse().entrySet()) {
ParamType param = entry.getKey();
if (REQUIRES_SCHEMA_SPEC.contains(param)) {
continue;
}
SqlType sqlType = entry.getValue();
assertThat(SchemaConverters.functionToSqlConverter().toSqlType(param), is(sqlType));
}
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class SchemaConvertersTest method shouldGetParamTypesForAllSqlTypes.
@Test
public void shouldGetParamTypesForAllSqlTypes() {
for (final Entry<SqlType, ParamType> entry : SQL_TO_FUNCTION.entrySet()) {
final SqlType sqlType = entry.getKey();
final ParamType javaType = entry.getValue();
final ParamType result = SchemaConverters.sqlToFunctionConverter().toFunctionType(sqlType);
assertThat(result, equalTo(javaType));
}
}
Aggregations