use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetFunction.
@Test
public void shouldGetFunction() throws NoSuchMethodException {
final Type type = getClass().getDeclaredMethod("functionType", Function.class).getGenericParameterTypes()[0];
final ParamType schema = UdfUtil.getSchemaFromType(type);
assertThat(schema, instanceOf(LambdaType.class));
assertThat(((LambdaType) schema).inputTypes(), equalTo(ImmutableList.of(ParamTypes.LONG)));
assertThat(((LambdaType) schema).returnType(), equalTo(ParamTypes.INTEGER));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetPartialGenericTriFunction.
@Test
public void shouldGetPartialGenericTriFunction() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("partialGenericTriFunctionType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
assertThat(returnType, is(LambdaType.of(ImmutableList.of(GenericType.of("T"), ParamTypes.BOOLEAN, GenericType.of("U")), ParamTypes.INTEGER)));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetGenericTriFunction.
@Test
public void shouldGetGenericTriFunction() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("genericTriFunctionType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
assertThat(returnType, is(LambdaType.of(ImmutableList.of(GenericType.of("T"), GenericType.of("U"), GenericType.of("V")), GenericType.of("W"))));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetMapSchemaFromMapClass.
@Test
public void shouldGetMapSchemaFromMapClass() throws NoSuchMethodException {
final Type type = getClass().getDeclaredMethod("mapType", Map.class).getGenericParameterTypes()[0];
final ParamType schema = UdfUtil.getSchemaFromType(type);
assertThat(schema, instanceOf(MapType.class));
assertThat(((MapType) schema).value(), equalTo(ParamTypes.INTEGER));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetGenericSchemaFromPartialParameterizedType.
@Test
public void shouldGetGenericSchemaFromPartialParameterizedType() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("partialGenericMapType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
assertThat(returnType, is(MapType.of(ParamTypes.LONG, GenericType.of("V"))));
}
Aggregations