This article shows how to use the common commands to operate functions in the MaxCompute client. 

You can also operate functions through the visualized online data development tools in DataWorks.

Create a function

The command format is as follows:
Parameters information:
  • function_name: UDF name, which is the name referenced in SQL.
  • package_to_class:For Java UDF,  this name is a fully qualified class name (from top-level package name to UDF class name). This parameter must be in double quotation marks.
  • resource_list: resources list used by UDF.
    • The resource which contains UDF code must be included in the list.
    • If the your code reads the resource file by distributed cache interface, this list also contains the list of resource files read by the UDF.
    • The resource list is composed of multiple resource names, separated by comma (,). The resource list must be in double quotation marks.


Suppose that the Java UDF class org.alidata.odps.udf.examples.Lower is in my_lower.jar. Create the UDF my_lower function as follows:
CREATE FUNCTION test_lower AS 'org.alidata.odps.udf.examples.Lower' USING 'my_lower.jar';
  • Similarly to the resource files, UDF the same name can only be registered once.
  • Generally UDF cannot overwrite system built-in functions.  Only the project owner has right to overwrite the built-in functions.  If you use a UDF which overwrites the built-in function, the warning is triggered in Summary after SQL execution.

Delete a function

The command format is as follows:
The example is as follows:
DROP FUNCTION test_lower;

List functions

The command format is as follows:
list functions; --View all user-defined functions in current project.
list functions -p my_project; --View all user-defined functions in the project 'my_project'.