Project Explorer of MaxCompute Studio provides a visual editor. The visual editor helps you create user-defined functions (UDFs) in your MaxCompute project. The editor also provides an entry point to help you view the code of MaxCompute UDFs and delete the UDFs. This topic describes how to use Project Explorer to create, view, or delete MaxCompute UDFs in a visualized manner.

Background information

The following table describes the operations that you can perform on built-in functions and MaxCompute UDFs in MaxCompute Studio.

Operation Built-in function MaxCompute UDF Description
Create a function Not supported Supported N/A.
View the syntax or code of a function Supported Supported
  • Built-in functions: You can view the syntax of built-in functions but cannot view the code of built-in functions.
  • MaxCompute UDFs: You can view the syntax and code of MaxCompute UDFs.
Modify a function Not supported Not supported
  • Built-in functions: You cannot modify built-in functions.
  • MaxCompute UDFs: If you want to modify an existing MaxCompute UDF, you must delete the UDF, redevelop the UDF, package UDF code, upload the UDF package, and create the UDF.
Delete a function Not supported Supported N/A.

Create a function

Note Before you create a function, you must make sure that the resources on which the function depends are uploaded to your MaxCompute project.
  1. In the main menu bar of IntelliJ IDEA, choose MaxCompute > Create UDF.
  2. In the Create Function dialog box, configure the parameters.
    Create Function dialog box
    Parameter Description
    MaxCompute project The name of the MaxCompute project in which you want to create a function.
    Function name The name of the function that you want to create. The function name is used when you call the function in SQL statements. The function name must be unique in the MaxCompute project to which the function belongs.

    You can click Project Explorer in the left-side navigation pane of IntelliJ IDEA and expand the Functions folder for the MaxCompute project in the navigation tree to view the names of existing functions.

    Using resources The resource file on which the function depends. You can select the required resource file from the resource list. If the function depends on multiple resource files, press and hold the Ctrl key, and click the required files in sequence to select them.
    Main class The class of the function that you want to create. The class is defined in the JAR file or the PY file on which the function depends.
    Force update if already exists If you select this option, the function that you create overwrites the existing function that has the same name in your MaxCompute project.
  3. In the Create Function dialog box, click OK.
  4. In the Project Explorer section, right-click the Functions folder for the MaxCompute project and select Refresh meta to refresh function information. Then, you can view the function that you created.

View the syntax or code of a function

  • Built-in functions

    In the left-side navigation pane of IntelliJ IDEA, click Project Explorer. Expand the Functions folder for the MaxCompute project, and double-click the name of a built-in function in the Builtln folder to view the syntax of the function.

  • MaxCompute UDFs
    In the left-side navigation pane of IntelliJ IDEA, click Project Explorer. In the Functions folder for the MaxCompute project, double-click the name of a function in the UserDefined folder to view the code of the function. You can also right-click the name of a function and select Show function detail to view the code of the function. To view the syntax of a function, you can click the name of the function in the UserDefined folder. View the code of a function

Delete a function

  1. In the left-side navigation pane of IntelliJ IDEA, click Project Explorer. Expand the Functions folder for the MaxCompute project, right-click the name of the function that you want to delete, and then select Delete function from server.
    Delete a function
  2. In the Confirmation Required dialog box, click OK.
  3. Right-click the Functions folder for the MaxCompute project and select Refresh meta to refresh function information. After the refresh, the deleted function is no longer displayed in the function list.