use of io.confluent.ksql.rest.entity.ArgumentInfo in project ksql by confluentinc.
the class DescribeFunctionExecutor method getFunctionInfo.
private static FunctionInfo getFunctionInfo(final List<ParameterInfo> argTypes, final ParamType returnTypeSchema, final String description, final boolean variadic) {
final List<ArgumentInfo> args = new ArrayList<>();
for (int i = 0; i < argTypes.size(); i++) {
final ParameterInfo param = argTypes.get(i);
final boolean isVariadic = variadic && i == (argTypes.size() - 1);
final String type = isVariadic ? ((ArrayType) param.type()).element().toString() : param.type().toString();
args.add(new ArgumentInfo(param.name(), type, param.description(), isVariadic));
}
return new FunctionInfo(args, returnTypeSchema.toString(), description);
}
use of io.confluent.ksql.rest.entity.ArgumentInfo in project ksql by confluentinc.
the class DescribeFunctionExecutorTest method shouldDescribeUDTF.
@Test
public void shouldDescribeUDTF() {
// When:
final FunctionDescriptionList functionList = (FunctionDescriptionList) CUSTOM_EXECUTORS.describeFunction().execute((ConfiguredStatement<DescribeFunction>) engine.configure("DESCRIBE FUNCTION TEST_UDTF1;"), mock(SessionProperties.class), engine.getEngine(), engine.getServiceContext()).getEntity().orElseThrow(IllegalStateException::new);
// Then:
assertThat(functionList, new TypeSafeMatcher<FunctionDescriptionList>() {
@Override
protected boolean matchesSafely(final FunctionDescriptionList item) {
return item.getName().equals("TEST_UDTF1") && item.getType().equals(FunctionType.TABLE);
}
@Override
public void describeTo(final Description description) {
description.appendText(functionList.getName());
}
});
assertThat(functionList.getFunctions(), hasSize(2));
final FunctionInfo expected1 = new FunctionInfo(Arrays.asList(new ArgumentInfo("foo", "INT", "", false)), "INT", "test_udtf1 int");
assertTrue(functionList.getFunctions().contains(expected1));
final FunctionInfo expected2 = new FunctionInfo(Arrays.asList(new ArgumentInfo("foo", "DOUBLE", "", false)), "DOUBLE", "test_udtf1 double");
assertTrue(functionList.getFunctions().contains(expected2));
}
use of io.confluent.ksql.rest.entity.ArgumentInfo in project ksql by confluentinc.
the class ConsoleTest method shouldPrintFunctionDescription.
@Test
public void shouldPrintFunctionDescription() {
final KsqlEntityList entityList = new KsqlEntityList(ImmutableList.of(new FunctionDescriptionList("DESCRIBE FUNCTION foo;", "FOO", "Description that is very, very, very, very, very, very, very, very, very, " + "very, very, very, very, very, very, very, very, very, very, very, very long\n" + "and containing new lines\n" + "\tAND TABS\n" + "too!", "Andy", "v1.1.0", "some.jar", ImmutableList.of(new FunctionInfo(ImmutableList.of(new ArgumentInfo("arg1", "INT", "Another really, really, really, really, really, really, really," + "really, really, really, really, really, really, really, really " + " really, really, really, really, really, really, really, long\n" + "description\n" + "\tContaining Tabs\n" + "and stuff", true)), "LONG", "The function description, which too can be really, really, really, " + "really, really, really, really, really, really, really, really, really, " + "really, really, really, really, really, really, really, really, long\n" + "and contains\n\ttabs and stuff")), FunctionType.SCALAR)));
console.printKsqlEntityList(entityList);
final String output = terminal.getOutputString();
Approvals.verify(output, approvalOptions);
}
Aggregations