This topic describes how to use Function Studio to develop a user-defined function (UDF) and commit the UDF to the development environment in DataStudio.

Limits

Function Studio is available only in the China (Beijing), China (Shanghai), China (Shenzhen), and China (Hangzhou) regions.

Create a project

If you have Git code, you can import the Git code to create a project. You can import Git code only from code.aliyun.com.

  1. Go to the DataStudio page.
    1. Log on to the DataWorks console.
    2. In the left-side navigation pane, click Workspaces.
    3. In the top navigation bar, select the region where your workspace resides, find the workspace, and then click Data Analytics in the Actions column.
  2. On the DataStudio page, click the 1 icon in the upper-left corner and choose All Products > Data Development > Function Studio.
  3. On the Projects page, click Import Git Project.
  4. On the Create Project page, set the Git Repo URL, Name, and Description parameters and select a runtime environment.
    By default, the new project is not associated with the Git service. Therefore, the Settings dialog box appears after you set the Git Repo URL parameter. In this dialog box, set parameters on the SSH Key, Git Config, and Preference tabs and click Save.
    • On the SSH Key tab, set the Service parameter to code.aliyun.com, click Create SSH Key to generate a Secure Shell (SSH) public key, and then click Save.
    • On the Git Config tab, set the Username and Email parameters and click Save.
    • On the Preference tab, set the Font Size in Editor parameter based on your needs and click Save.
    Note If you want to modify Git settings after you create the project, go to the project editing page, move the pointer over Settings in the top navigation bar, and then select SSH Key, Git Config, or Preference as required.
  5. Click Submit.
    After you create the project, Function Studio automatically pulls Git code from the project.

Add the SSH public key to code.aliyun.com

After you set parameters on the SSH Key, Git Config, and Preference tabs, you can add the SSH public key to code.aliyun.com.

  1. Visit code.aliyun.com and click Settings in the left-side navigation pane.
  2. On the page that appears, click SSH Public Key in the left-side navigation pane. On the SSH Public Key page, click Add SSH Public Key in the upper-right corner.
  3. On the Add SSH Public Key page, enter the SSH public key that is generated on the SSH Key tab and click Add.

Test the class to run

  1. On the project editing page, double-click the class that you want to test in the left-side navigation pane and click the Run Program icon in the upper-right corner.
  2. In the Run/Debug Configurations dialog box, set parameters for the class.
  3. Click Run. The test results appear in the Output section.
    Note
    • The initial running process takes a longer time period. When you run the class again, the running duration is similar to that in a local integrated development environment (IDE).
    • You can also select the class from the drop-down list in the upper-right corner and click the Run Program icon.

Commit the UDF and resource to the development environment in DataStudio

After you verify that code is correct, commit the UDF and resource to the development environment in DataStudio.

  • Commit the resource to the development environment in DataStudio.
    1. On the project editing page, move the pointer over the Submit icon and select Submit Resource to Development Environment.
    2. In the Submit Resource to DataStudio Development Environment dialog box, set the Target Workspace, Target Workflow, and Resource parameters.
    3. Click OK.
  • Commit the UDF to the development environment in DataStudio.
    1. On the project editing page, move the pointer over the Submit icon and select Submit Function to Development Environment.
    2. In the Submit Function to DataStudio Development Environment dialog box, set the Target Workspace, Target Workflow, Resource, Class, and Function parameters.
    3. Click OK.

After you commit the resource and UDF to the development environment in DataStudio, you can use them in SQL nodes.