All Products
Search
Document Center

MaxCompute:Develop Java UDFs with IntelliJ IDEA

Last Updated:Apr 28, 2026

This topic describes how to use the MaxCompute Studio plugin in IntelliJ IDEA to develop a Java user-defined function (UDF) that converts uppercase letters to lowercase.

Prerequisites

Before you begin, complete the following prerequisites in IntelliJ IDEA:

  1. Install MaxCompute Studio

  2. Create a connection to a MaxCompute project

  3. Create a MaxCompute Java module

Procedure

  1. Write a Java UDF.

    1. In the Project tool window, right-click the module's source directory, src > main > java, and select New > MaxCompute Java.

      新建Java Class

    2. In the Create new MaxCompute java class dialog box, select UDF, enter a name in the Name field, and then press Enter. For example, name the Java class Lower.

      选择类型填写名称

      Name is the name of the MaxCompute Java class. If you have not created a package, you can enter packagename.classname to automatically generate a package.

    3. In the code editor, enter the following code.

      Code editing areaThe UDF code example is as follows.

      package <packagename>;
      import com.aliyun.odps.udf.UDF;
      public final class Lower extends UDF {
          public String evaluate(String s) {
              if (s == null) { 
                 return null; 
              }
                 return s.toLowerCase();
          }
      }
  2. Debug the UDF to verify that it runs correctly.

    1. In the java directory, right-click the Java file and select Run.

    2. In the Run/Debug Configurations dialog box, configure the parameters.

      debug

      • MaxCompute project: The MaxCompute project where the UDF runs. For a local run, select local.

      • MaxCompute table: The name of the MaxCompute table used by the UDF.

      • Table columns: The column information of the MaxCompute table used by the UDF.

    3. Click OK. The following figure shows the result.

  3. Register the MaxCompute UDF.

    1. Right-click the UDF Java file and select Deploy to server....

    2. In the Package a jar, submit resource and register function dialog box, configure the following parameters.

      • MaxCompute project: The project where the UDF will be registered. You can typically keep the default value.

      • Resource file: The path to the dependent resource file. You can keep the default value.

      • Resource name: The name of the dependent resource. You can keep the default value.

      • Function name: The registration name for the function. This name is used to call the UDF in SQL statements. For example, Lower_test.

    3. Click OK to complete the UDF registration.

  4. Call the UDF.

    In the Project Explorer pane on the left, right-click the target MaxCompute project, select Open in Console, enter the SQL statement to call the UDF in the console, and press Enter to run it.调用UDF

    select Lower_test('ALIYUN');

    This result confirms that the Lower_test Java UDF is ready to use.