You can debug UDFs (Java only), UDAFs, and UDTFs.
Debug UDFs (Java only)
- Create a main method.
Currently, Function Studio only allows you to call and debug UDFs online by using the main method.
- Set the debugging configuration.
Click Run/Debug Config in the upper-right corner.
Select the main method you just created. Other information is automatically generated.
Parameter Description Main class Required. The main method you want to debug. VM options Optional. The JVM startup parameter. Program Variables Optional. The startup variables. JRE Currently, only JDK1.8 is supported. PORT The HTTP port you must open. This parameter is optional for UDF, UDAF, and UDTF projects. ECS instance The instance type. Enable Hot Code Replacement Indicates whether to enable hot code replacement.
- Enable debugging.
In the Lower.java file, set a breakpoint for the evaluate method and click Debug.
After debugging is enabled, you can debug the method. You can click Step In to step into the UDF and view the variables.
To debug UDAFs, you must manually construct the relevant data and use a warehouse to simulate the MaxCompute table. The schema and data of the table are saved in the warehouse, which can be used to compile the main method for testing.
After the warehouse is initialized, call relevant UDAFs for testing.
You can debug UDTFs in the same way as you debug UDAFs. The initialized project already provides the UDTF test class. You can directly run the class to simulate the data and debug UDTFs.
Click Run. If the application throws no error, the UDTF test is passed.