This topic describes how to develop user-defined functions (UDFs) in MaxCompute Studio. This includes how to write and debug UDFs.
You can follow the instructions in this topic to develop UDFs, or chooseto directly create UDFs.
- In the Project tool window, expand your MaxCompute Java module and choose . Then, right-click java and choose .
- Specify Name and Kind, and click OK.
- Name: the name of the MaxCompute Java class. If no package is created, enter packagename.classname. The system automatically creates a package.
- Kind: the category of the MaxCompute Java class. Select UDF. Supported categories include custom functions (UDF, UDAF, and UDTF), MapReduce (Driver, Mapper, and Reducer), and non-structural development frameworks (StorageHandler, Extractor, and Outputer).
- After you create a UDF class, develop a UDF Java program in the editor.
For more information about examples of Java UDFs, see.
Perform local run to debug UDFs
Perform local run to test the UDF and check whether the results meet your expectation.
- Right-click the compiled Java script and select Run.
- In the Run/Debug Configurations dialog box, configure the running parameters.
- MaxCompute project: the MaxCompute project where the UDF runs. To perform local run, select local.
- MaxCompute table: the name of the MaxCompute table where the UDF runs.
- Table columns: the columns in the MaxCompute table where the UDF runs.
- Click OK to run the UDF.
- The system reads the specified table data 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.