use of com.facebook.presto.sql.tree.AlterFunction in project presto by prestodb.
the class AlterFunctionTask method execute.
@Override
public ListenableFuture<?> execute(AlterFunction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector) {
Analyzer analyzer = new Analyzer(session, metadata, sqlParser, accessControl, Optional.empty(), parameters, warningCollector);
analyzer.analyze(statement);
QualifiedObjectName functionName = qualifyObjectName(statement.getFunctionName());
AlterRoutineCharacteristics alterRoutineCharacteristics = new AlterRoutineCharacteristics(statement.getCharacteristics().getNullCallClause().map(com.facebook.presto.sql.tree.RoutineCharacteristics.NullCallClause::name).map(NullCallClause::valueOf));
metadata.getFunctionAndTypeManager().alterFunction(functionName, statement.getParameterTypes().map(types -> types.stream().map(TypeSignature::parseTypeSignature).collect(toImmutableList())), alterRoutineCharacteristics);
return immediateFuture(null);
}
use of com.facebook.presto.sql.tree.AlterFunction in project presto by prestodb.
the class TestSqlParser method testAlterFunction.
@Test
public void testAlterFunction() {
QualifiedName functionName = QualifiedName.of("testing", "default", "tan");
assertStatement("ALTER FUNCTION testing.default.tan\n" + "CALLED ON NULL INPUT", new AlterFunction(functionName, Optional.empty(), new AlterRoutineCharacteristics(Optional.of(CALLED_ON_NULL_INPUT))));
assertStatement("ALTER FUNCTION testing.default.tan(double)\n" + "RETURNS NULL ON NULL INPUT", new AlterFunction(functionName, Optional.of(ImmutableList.of("double")), new AlterRoutineCharacteristics(Optional.of(RETURNS_NULL_ON_NULL_INPUT))));
assertInvalidStatement("ALTER FUNCTION testing.default.tan", "No alter routine characteristics specified");
assertInvalidStatement("ALTER FUNCTION testing.default.tan\n" + "RETURNS NULL ON NULL INPUT\n" + "RETURNS NULL ON NULL INPUT", "Duplicate null-call clause: RETURNSNULLONNULLINPUT");
}
Aggregations