After developing and testing your Python program, upload it as a resource to your MaxCompute project before you can register a MaxCompute UDF. This topic describes how to upload a Python program as a MaxCompute resource and register a MaxCompute UDF.
Prerequisites
You have developed and tested your Python program. For more information about developing and testing Python programs, see Develop Python UDFs.
Background information
MaxCompute Studio provides a one-click feature to upload your Python program to MaxCompute and register a MaxCompute UDF. Use this method whenever possible.
You can also perform these two operations separately in MaxCompute Studio. To upload a Python program to MaxCompute, see Add resources. To register a MaxCompute UDF, see Register functions.
Procedure
In the IntelliJ IDEA interface, click Project in the navigation pane on the left. Right-click the target Python program under the scripts folder and select Deploy to server….
In the Submit resource and register function dialog box, configure the parameters listed in the following table.
Parameter name
Description
MaxCompute Project
The name of the target MaxCompute project. This field is auto-filled with the MaxCompute project that your Python program belongs to. You do not need to select a project from the drop-down list.
Resource file
The local path of the Python program after MaxCompute Studio uploads it as a resource.
Resource name
The name of the resource after the Python program is uploaded to the MaxCompute project.
Resource comment
A comment for the Python resource.
Extra resources
Additional resource files that the MaxCompute UDF depends on. Click the required resource files in the resources list. To select multiple resource files, hold Ctrl and click each file.
Main class
The class name of the new MaxCompute UDF, formatted as Python script name.class name.
Function name
The name of the MaxCompute UDF registered by MaxCompute Studio based on the Python resource. This is also the function name you use when calling the UDF in SQL.
Force update if already exists
Select this option to replace an existing function or resource in the MaxCompute project with the new one if a name conflict occurs.
Click OK to complete the resource upload and MaxCompute UDF registration.
After completing these steps, you can call the MaxCompute UDF in SQL.