use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.
the class AbstractTestFunctions method registerScalar.
protected void registerScalar(Class<?> clazz) {
Metadata metadata = functionAssertions.getMetadata();
List<SqlFunction> functions = new FunctionListBuilder().scalars(clazz).getFunctions();
metadata.getFunctionAndTypeManager().registerBuiltInFunctions(functions);
}
use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.
the class AbstractTestFunctions method registerParametricScalar.
protected void registerParametricScalar(Class<?> clazz) {
Metadata metadata = functionAssertions.getMetadata();
List<SqlFunction> functions = new FunctionListBuilder().scalar(clazz).getFunctions();
metadata.getFunctionAndTypeManager().registerBuiltInFunctions(functions);
}
use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.
the class FunctionSignatureMatcher method identifyApplicableFunctions.
private List<ApplicableFunction> identifyApplicableFunctions(Collection<? extends SqlFunction> candidates, List<TypeSignatureProvider> actualParameters, boolean allowCoercion) {
ImmutableList.Builder<ApplicableFunction> applicableFunctions = ImmutableList.builder();
for (SqlFunction function : candidates) {
Signature declaredSignature = function.getSignature();
Optional<Signature> boundSignature = new SignatureBinder(functionAndTypeManager, declaredSignature, allowCoercion).bind(actualParameters);
if (boundSignature.isPresent()) {
applicableFunctions.add(new ApplicableFunction(declaredSignature, boundSignature.get(), function.isCalledOnNullInput()));
}
}
return applicableFunctions.build();
}
use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.
the class TestFunctionAndTypeManager method testListingVisibilityBetaFunctionsDisabled.
@Test
public void testListingVisibilityBetaFunctionsDisabled() {
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
List<SqlFunction> functions = functionAndTypeManager.listFunctions(TEST_SESSION, Optional.empty(), Optional.empty());
List<String> names = transform(functions, input -> input.getSignature().getNameSuffix());
assertTrue(names.contains("length"), "Expected function names " + names + " to contain 'length'");
assertTrue(names.contains("stddev"), "Expected function names " + names + " to contain 'stddev'");
assertTrue(names.contains("rank"), "Expected function names " + names + " to contain 'rank'");
assertFalse(names.contains("quantiles_at_values"), "Expected function names " + names + " not to contain 'quantiles_at_values'");
assertFalse(names.contains("like"), "Expected function names " + names + " not to contain 'like'");
assertFalse(names.contains("$internal$sum_data_size_for_stats"), "Expected function names " + names + " not to contain '$internal$sum_data_size_for_stats'");
assertFalse(names.contains("$internal$max_data_size_for_stats"), "Expected function names " + names + " not to contain '$internal$max_data_size_for_stats'");
}
use of com.facebook.presto.spi.function.SqlFunction in project presto by prestodb.
the class TestFunctionAndTypeManager method testDuplicateFunctions.
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "\\QFunction already registered: presto.default.custom_add(bigint,bigint):bigint\\E")
public void testDuplicateFunctions() {
List<SqlFunction> functions = new FunctionListBuilder().scalars(CustomFunctions.class).getFunctions().stream().filter(input -> input.getSignature().getNameSuffix().equals("custom_add")).collect(toImmutableList());
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
functionAndTypeManager.registerBuiltInFunctions(functions);
functionAndTypeManager.registerBuiltInFunctions(functions);
}
Aggregations