DataWorks allows you to develop functions in Python and Java. This topic describes how to create a MaxCompute function.


Required resources are uploaded to create a function.


  1. Go to the DataStudio page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. In the top navigation bar, select the region where your workspace resides, find the workspace, and then click Data Analytics in the Actions column.
  2. Create a workflow. For more information, see Create a workflow.
  3. Write code in an offline Java environment and compress the code to a JAR package. Then, create a JAR resource and commit the resource. For more information, see Create MaxCompute resources.
  4. Create a function.
    1. Find the created workflow, right-click MaxCompute, and then choose Create > Function.
    2. In the Create Function dialog box, set the Function Name and Location parameters.
    3. Click Create.
    4. In the Register Function section, set the parameters.
      Register Function section
      Parameter Description
      Function Type The type of the function. Valid values: Mathematical Function, Aggregate Function, String Function, Date Function, Analytic Function, and Other.
      Engine Instance MaxCompute By default, the parameter cannot be modified.
      Function Name The name of the user defined function (UDF). You can reference the function in SQL statements by using the function name. The function name must be globally unique and cannot be changed after the function is created.
      Owner This parameter is automatically set.
      Class Name Required. The name of the class that is used to implement the UDF.
      Note If the resource is a Python resource, enter the class name in the Python resource name.Class name format. Do not include the .py extension in the resource name.
      Resources Required. You can search for existing resources in the current workspace in fuzzy match mode.
      Description The brief description of the current UDF.
      Expression Syntax The syntax of the UDF. Example: test.
      Parameter Description The description of the input and output parameters that are supported.
      Return Value Optional. The value to return. Example: 1.
      Example Optional. An example of the function.
  5. Click the Save icon in the toolbar.
  6. Commit the function.
    1. Click the Submit icon in the toolbar.
    2. In the Commit Node dialog box, enter your comments in the Change description field.
    3. Click OK.