Search in sources :

Example 16 with FunctionMetadata

use of io.trino.metadata.FunctionMetadata in project trino by trinodb.

the class TestAnnotationEngineForScalars method testParametricScalarParse.

@Test
public void testParametricScalarParse() {
    Signature expectedSignature = new Signature("parametric_scalar", ImmutableList.of(typeVariable("T")), ImmutableList.of(), new TypeSignature("T"), ImmutableList.of(new TypeSignature("T")), false);
    List<SqlScalarFunction> functions = ScalarFromAnnotationsParser.parseFunctionDefinition(ParametricScalarFunction.class);
    assertEquals(functions.size(), 1);
    ParametricScalar scalar = (ParametricScalar) functions.get(0);
    assertImplementationCount(scalar, 0, 2, 0);
    FunctionMetadata functionMetadata = scalar.getFunctionMetadata();
    assertEquals(functionMetadata.getSignature(), expectedSignature);
    assertTrue(functionMetadata.isDeterministic());
    assertFalse(functionMetadata.isHidden());
    assertEquals(functionMetadata.getDescription(), "Parametric scalar description");
}
Also used : FunctionMetadata(io.trino.metadata.FunctionMetadata) TypeSignature(io.trino.spi.type.TypeSignature) Signature(io.trino.metadata.Signature) TypeSignature(io.trino.spi.type.TypeSignature) BoundSignature(io.trino.metadata.BoundSignature) ParametricScalar(io.trino.operator.scalar.ParametricScalar) SqlScalarFunction(io.trino.metadata.SqlScalarFunction) Test(org.testng.annotations.Test)

Aggregations

FunctionMetadata (io.trino.metadata.FunctionMetadata)16 SqlScalarFunction (io.trino.metadata.SqlScalarFunction)13 ParametricScalar (io.trino.operator.scalar.ParametricScalar)13 Test (org.testng.annotations.Test)13 BoundSignature (io.trino.metadata.BoundSignature)12 Signature (io.trino.metadata.Signature)12 TypeSignature (io.trino.spi.type.TypeSignature)11 FunctionDependencies (io.trino.metadata.FunctionDependencies)6 ImplementationDependency (io.trino.operator.annotations.ImplementationDependency)5 LiteralImplementationDependency (io.trino.operator.annotations.LiteralImplementationDependency)4 TypeImplementationDependency (io.trino.operator.annotations.TypeImplementationDependency)4 ChoicesScalarFunctionImplementation (io.trino.operator.scalar.ChoicesScalarFunctionImplementation)4 ParametricScalarImplementationChoice (io.trino.operator.scalar.annotations.ParametricScalarImplementation.ParametricScalarImplementationChoice)4 FunctionBinding (io.trino.metadata.FunctionBinding)3 ImmutableList (com.google.common.collect.ImmutableList)2 AggregationFunctionMetadata (io.trino.metadata.AggregationFunctionMetadata)2 TrinoException (io.trino.spi.TrinoException)2 List (java.util.List)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1