Search in sources :

Example 1 with WindowFunctionSignature

use of io.trino.spi.function.WindowFunctionSignature in project trino by trinodb.

the class WindowAnnotationsParser method parse.

private static SqlWindowFunction parse(Class<? extends WindowFunction> clazz, WindowFunctionSignature window) {
    List<TypeVariableConstraint> typeVariables = ImmutableList.of();
    if (!window.typeVariable().isEmpty()) {
        typeVariables = ImmutableList.of(typeVariable(window.typeVariable()));
    }
    List<TypeSignature> argumentTypes = Stream.of(window.argumentTypes()).map(type -> parseTypeSignature(type, ImmutableSet.of())).collect(toImmutableList());
    Signature signature = new Signature(window.name(), typeVariables, ImmutableList.of(), parseTypeSignature(window.returnType(), ImmutableSet.of()), argumentTypes, false);
    Optional<String> description = Optional.ofNullable(clazz.getAnnotation(Description.class)).map(Description::value);
    boolean deprecated = clazz.getAnnotationsByType(Deprecated.class).length > 0;
    return new SqlWindowFunction(signature, description, deprecated, new ReflectionWindowFunctionSupplier(window.argumentTypes().length, clazz));
}
Also used : WindowFunctionSignature(io.trino.spi.function.WindowFunctionSignature) TypeVariableConstraint(io.trino.metadata.TypeVariableConstraint) ImmutableSet(com.google.common.collect.ImmutableSet) Description(io.trino.spi.function.Description) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) List(java.util.List) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Stream(java.util.stream.Stream) ImmutableList(com.google.common.collect.ImmutableList) WindowFunction(io.trino.spi.function.WindowFunction) Signature.typeVariable(io.trino.metadata.Signature.typeVariable) Optional(java.util.Optional) Signature(io.trino.metadata.Signature) TypeSignature(io.trino.spi.type.TypeSignature) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) TypeSignature(io.trino.spi.type.TypeSignature) Description(io.trino.spi.function.Description) WindowFunctionSignature(io.trino.spi.function.WindowFunctionSignature) TypeSignatureTranslator.parseTypeSignature(io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature) Signature(io.trino.metadata.Signature) TypeSignature(io.trino.spi.type.TypeSignature) TypeVariableConstraint(io.trino.metadata.TypeVariableConstraint)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Signature (io.trino.metadata.Signature)1 Signature.typeVariable (io.trino.metadata.Signature.typeVariable)1 TypeVariableConstraint (io.trino.metadata.TypeVariableConstraint)1 Description (io.trino.spi.function.Description)1 WindowFunction (io.trino.spi.function.WindowFunction)1 WindowFunctionSignature (io.trino.spi.function.WindowFunctionSignature)1 TypeSignature (io.trino.spi.type.TypeSignature)1 TypeSignatureTranslator.parseTypeSignature (io.trino.sql.analyzer.TypeSignatureTranslator.parseTypeSignature)1 List (java.util.List)1 Optional (java.util.Optional)1 Stream (java.util.stream.Stream)1