use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetGenericFunction.
@Test
public void shouldGetGenericFunction() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("genericFunctionType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
assertThat(returnType, is(LambdaType.of(ImmutableList.of(GenericType.of("T")), GenericType.of("U"))));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetGenericSchemaFromType.
@Test
public void shouldGetGenericSchemaFromType() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("genericType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
MatcherAssert.assertThat(returnType, CoreMatchers.is(GenericType.of("T")));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetPartialGenericFunction.
@Test
public void shouldGetPartialGenericFunction() throws NoSuchMethodException {
// Given:
final Type genericType = getClass().getMethod("partialGenericFunctionType").getGenericReturnType();
// When:
final ParamType returnType = UdfUtil.getSchemaFromType(genericType);
// Then:
assertThat(returnType, is(LambdaType.of(ImmutableList.of(ParamTypes.LONG), GenericType.of("U"))));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdfUtilTest method shouldGetTriFunction.
@Test
public void shouldGetTriFunction() throws NoSuchMethodException {
final Type type = getClass().getDeclaredMethod("triFunctionType", TriFunction.class).getGenericParameterTypes()[0];
final ParamType schema = UdfUtil.getSchemaFromType(type);
assertThat(schema, instanceOf(LambdaType.class));
assertThat(((LambdaType) schema).inputTypes(), equalTo(ImmutableList.of(ParamTypes.LONG, ParamTypes.INTEGER, ParamTypes.BOOLEAN)));
assertThat(((LambdaType) schema).returnType(), equalTo(ParamTypes.BOOLEAN));
}
use of io.confluent.ksql.function.types.ParamType in project ksql by confluentinc.
the class UdafTypes method getInputSchema.
List<ParameterInfo> getInputSchema(final String inSchema) {
validateStructAnnotation(inputType, inSchema, "paramSchema");
final ParamType inputSchema = getSchemaFromType(inputType, inSchema);
return ImmutableList.<ParameterInfo>builder().add(new ParameterInfo("val", inputSchema, "", false)).addAll(literalParams).build();
}
Aggregations