Search in sources :

Example 11 with SqlFunction

use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.

the class TestFunctionAndTypeManager method testExactMatchBeforeCoercion.

@Test
public void testExactMatchBeforeCoercion() {
    FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
    boolean foundOperator = false;
    for (SqlFunction function : functionAndTypeManager.listOperators()) {
        OperatorType operatorType = tryGetOperatorType(function.getSignature().getName()).get();
        if (operatorType == CAST || operatorType == SATURATED_FLOOR_CAST) {
            continue;
        }
        if (!function.getSignature().getTypeVariableConstraints().isEmpty()) {
            continue;
        }
        if (function.getSignature().getArgumentTypes().stream().anyMatch(TypeSignature::isCalculated)) {
            continue;
        }
        BuiltInFunctionHandle exactOperator = (BuiltInFunctionHandle) functionAndTypeManager.resolveOperator(operatorType, fromTypeSignatures(function.getSignature().getArgumentTypes()));
        assertEquals(exactOperator.getSignature(), function.getSignature());
        foundOperator = true;
    }
    assertTrue(foundOperator);
}
Also used : TypeSignature(com.facebook.presto.common.type.TypeSignature) TypeSignature.parseTypeSignature(com.facebook.presto.common.type.TypeSignature.parseTypeSignature) FunctionAndTypeManager.createTestFunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager) OperatorType.tryGetOperatorType(com.facebook.presto.common.function.OperatorType.tryGetOperatorType) OperatorType(com.facebook.presto.common.function.OperatorType) SqlFunction(com.facebook.presto.spi.function.SqlFunction) Test(org.testng.annotations.Test)

Aggregations

SqlFunction (com.facebook.presto.spi.function.SqlFunction)11 FunctionAndTypeManager.createTestFunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager)5 Test (org.testng.annotations.Test)5 OperatorType (com.facebook.presto.common.function.OperatorType)4 OperatorType.tryGetOperatorType (com.facebook.presto.common.function.OperatorType.tryGetOperatorType)4 TypeSignature (com.facebook.presto.common.type.TypeSignature)4 TypeSignature.parseTypeSignature (com.facebook.presto.common.type.TypeSignature.parseTypeSignature)4 Signature (com.facebook.presto.spi.function.Signature)4 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)3 Session (com.facebook.presto.Session)2 FunctionListBuilder (com.facebook.presto.metadata.FunctionListBuilder)2 Metadata (com.facebook.presto.metadata.Metadata)2 PrestoException (com.facebook.presto.spi.PrestoException)2 Parameter (com.facebook.presto.spi.function.Parameter)2 SqlInvokedFunction (com.facebook.presto.spi.function.SqlInvokedFunction)2 TypeSignatureProvider (com.facebook.presto.sql.analyzer.TypeSignatureProvider)2 ArrayList (java.util.ArrayList)2 TEST_SESSION (com.facebook.presto.SessionTestUtils.TEST_SESSION)1 EXPERIMENTAL_FUNCTIONS_ENABLED (com.facebook.presto.SystemSessionProperties.EXPERIMENTAL_FUNCTIONS_ENABLED)1