Flink resources and functions

更新时间:
复制 MD 格式

Data Studio lets you visually create and manage Flink Jar, Flink File, and Flink Python resources for custom functions and data development.

Prerequisites

  • You have associated a fully managed Flink compute resource with your workspace. Resources and functions are created based on this compute resource.

  • You have your resource files ready for upload from your local machine.

Create and use resources

Resources

In Data Studio, you can upload local resources to Flink through DataWorks. These resources can be used to develop Flink jobs or to create custom functions.

Limitations

Uploaded resources must comply with the following limits:

  • Resource size:

    • Online editing: The maximum size is 10 MB for a Python resource and 500 KB for a File resource.

    • Upload from a local file: The maximum size for a single resource is 500 MB.

    • Upload from an OSS file: The maximum size for a single resource is 500 MB.

  • Resource publishing: If you use a standard mode workspace, you must publish the resource to the production environment before you can use it.

    Note

    Data source information may differ between development and production environments. Before you query tables or resources, confirm the data source information for the current environment.

  • Resource management: In DataWorks, you can view and manage only the resources that are uploaded through the DataWorks UI.

Create a resource

Upload Flink resources from a local file. A created resource can be referenced directly in data development or registered as a function. Flink resources include the following types:

  1. On the Resource Management page, create a resource, which opens the Create Resource and Function dialog box. Configure the resource Type, storage Path, and resource Name.

  2. After you create the resource, upload a local file to it as the file source.

  3. In the top toolbar, Save and Publish the resource, because only deployed resources can be used in data development.

Use a resource

After you create a resource, open a data development node for editing. Click Resource Management in the left navigation bar, find the target resource or function, right-click it, and select Insert Resource Path. After the resource is referenced, code in the format --@resource_reference{"Resource Name"} is displayed.

Note

For example, a Flink SQL Streaming node displays the format --@resource_reference{"example.jar"}. The display format may vary by node type. Refer to the actual interface for details.

You can also register a resource as a function and use it in data development nodes.

Create and use functions

Functions

In Data Studio Resource Management, you can register resources as functions. For data development, you can use built-in Flink functions and Flink custom functions.

Create a function

  1. On the Resource Management page, create a function, which opens the Create Resource and Function dialog box. Configure the function Type, storage Path, and function Name.

  2. Click Confirm to create a function resource, and then configure the function information based on the function type.

    Before you configure a Flink function, make sure that you have created the Flink cluster as a compute resource in DataWorks and have uploaded the required Flink resource. The following table describes the parameters of a Flink function.

    Parameter

    Description

    Function type

    Select a function type: MATH (mathematical functions), AGGREGATE (aggregate functions), STRING (string processing functions), DATE (date functions), ANALYTIC (window functions), or OTHER (other functions).

    Flink cluster

    Select a registered Flink cluster from the drop-down list.

    Resource List

    Only Flink Jar resources can be selected from the drop-down list in the visual interface.

    Command Format

    An example of how to use the UDF.

  3. In the top toolbar, Save and Publish the function, because only deployed functions can be used in data development.

Use a function

After a function is created and deployed, open a data development node for editing. Click Resource Management in the left navigation bar, find the target resource or function, right-click it, and select Insert Function. The custom function name is automatically inserted on the current node editing page, for example: example_function().

Manage resources and functions

After you upload resources or create functions through the Data Studio visual interface, you can manage them on the resource management page by clicking the target resource or function.

  • View version history: Click the version button on the right side of the resource or function editor page to view and compare saved or submitted function versions and see changes between different versions.

    Note

    For version comparison, you must select at least two versions.

  • Delete a resource or function: Right-click the target resource or function and click the Delete button to delete it.

    To delete the resource or function in the production environment, you must deploy the task and deploy the deletion to the production environment. After the deployment succeeds, the resource or function is synchronously deleted from the production environment.