This topic describes how to develop a user-defined functions (UDF) in MaxCompute Studio. This includes how to write and debug a UDF.
You can follow the instructions in this topic to develop a UDF, or chooseto directly create a UDF.
Write a UDF
- In the Project tool window, expand your MaxCompute Java module and choose . Then, right-click java and choose .
- Specify Name, select the UDF type, and press Enter.
- Name: the name of the MaxCompute Java class. If no package is created, enter packagename.classname. The system automatically creates a package.
- Select the UDF type.
- After you create a MaxCompute java class, develop a Java program in the editor.
Perform a local run to debug the UDF
Perform a local run to test the UDF and check whether the results meet your expectations.
- Right-click the compiled Java script and select Run.
- In the Run/Debug Configurations dialog box, configure the runtime parameters.
- MaxCompute project: the MaxCompute project in which the UDF runs. To perform a local run, select local.
- MaxCompute table: the name of the MaxCompute table in which the UDF runs.
- Table columns: the columns in the MaxCompute table in which the UDF runs.
- Click OK to run the UDF. Note
- The system reads data from the specified table in warehouse as the input during the local run. You can view the log output in the console.
- The system downloads the table data from the specified MaxCompute project to the warehouse directory. If the data is already downloaded, the system does not perform this step.