use of io.trino.operator.scalar.ScalarHeader in project trino by trinodb.
the class ScalarImplementationHeader method fromAnnotatedElement.
public static List<ScalarImplementationHeader> fromAnnotatedElement(AnnotatedElement annotated) {
ScalarFunction scalarFunction = annotated.getAnnotation(ScalarFunction.class);
ScalarOperator scalarOperator = annotated.getAnnotation(ScalarOperator.class);
Optional<String> description = parseDescription(annotated);
ImmutableList.Builder<ScalarImplementationHeader> builder = ImmutableList.builder();
if (scalarFunction != null) {
String baseName = scalarFunction.value().isEmpty() ? camelToSnake(annotatedName(annotated)) : scalarFunction.value();
builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.hidden(), scalarFunction.deterministic())));
for (String alias : scalarFunction.alias()) {
builder.add(new ScalarImplementationHeader(alias, new ScalarHeader(description, scalarFunction.hidden(), scalarFunction.deterministic())));
}
}
if (scalarOperator != null) {
builder.add(new ScalarImplementationHeader(scalarOperator.value(), new ScalarHeader(description, true, true)));
}
List<ScalarImplementationHeader> result = builder.build();
checkArgument(!result.isEmpty());
return result;
}
Aggregations