Search in sources :

Example 1 with ScalarHeader

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;
}
Also used : ScalarOperator(io.trino.spi.function.ScalarOperator) ScalarFunction(io.trino.spi.function.ScalarFunction) ImmutableList(com.google.common.collect.ImmutableList) ScalarHeader(io.trino.operator.scalar.ScalarHeader)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ScalarHeader (io.trino.operator.scalar.ScalarHeader)1 ScalarFunction (io.trino.spi.function.ScalarFunction)1 ScalarOperator (io.trino.spi.function.ScalarOperator)1