use of io.confluent.ksql.function.types.GenericType 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.function.types.GenericType 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));
}
use of io.confluent.ksql.function.types.GenericType 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.function.types.GenericType 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.GenericType in project ksql by confluentinc.
the class GenericsUtilTest method shouldResolveSchemaWithMapping.
@Test
public void shouldResolveSchemaWithMapping() {
// Given:
final GenericType a = GenericType.of("A");
final ImmutableMap<GenericType, SqlType> mapping = ImmutableMap.of(a, SqlTypes.STRING);
// When:
final SqlType resolved = GenericsUtil.applyResolved(a, mapping);
// Then:
assertThat(resolved, is(SqlTypes.STRING));
}
Aggregations