Lindorm resources and functions
Data Studio allows you to create and manage Lindorm File resources and Lindorm Functions. You can upload local files to Lindorm through the resource management feature and register them as functions for use in Lindorm Spark nodes. This topic describes how to create and use Lindorm resources and functions in resource management.
Prerequisites
-
A Lindorm computing resource is bound to the workspace. All Lindorm resource and function operations are performed based on the Lindorm computing resource.
-
The resource file is ready for upload from your local machine.
-
Serverless resource group is already created for use.
Create and use resources
Resource description
In Data Studio resource management, you can upload local files to Lindorm to create Lindorm File resources. The created resources can be referenced in Lindorm nodes or used as dependencies for Lindorm Functions.
Create a resource
-
On the resource management page, click the create icon and choose .
-
In the Create Resource panel, configure the following parameters.
Parameter
Description
File Source
Select the source of the file. Currently, Local upload is supported.
File Content
Click Upload and select a local file to upload.
Storage Path
Select the storage path type. The following options are supported:
-
OSS: Store the file in an OSS path. After you select this option, select the destination OSS path below.
-
OSS Data Source: Store the file in a configured OSS data source path.
Resource Group
Select the scheduling resource group used to perform the resource upload operation.
-
-
After you create the resource, upload the local file as the file source.
-
On the toolbar, Save and Deploy the resource. Only deployed resources can be used in data development.
Use a resource
After a resource is created, you can reference it during data development. When editing a node, click Resource Management in the left-side navigation pane, find the target resource, and right-click to choose Use Resource. After the resource is referenced, a line of code in the format --@resource_reference{"resource_name"} is generated.
In addition to directly using resources, you can also register a resource as a function and then use it in development nodes.
Create and use functions
Function description
In Data Studio resource management, you can register Lindorm File resources as Lindorm Functions. A Lindorm Function is a user-defined function (UDF) registered in Lindorm. When you create a function, you need to associate it with an uploaded Lindorm File resource and specify the class name. After the function is created, it can be used in SQL statements of Lindorm Spark nodes.
Create a function
-
On the resource management page, click the create icon and choose .
-
Click OK to create a function and configure the function information.
Before you configure a Lindorm function, make sure that a Lindorm cluster is registered as a computing resource in DataWorks and that a Lindorm File resource has been uploaded. The following table describes the parameters of a Lindorm Function.
Parameter
Description
Function Type
Select the function type, including MATH (mathematical functions), AGGREGATE (aggregate functions), STRING (string processing functions), DATE (date functions), ANALYTIC (window functions), and OTHER (other functions).
Data Source
Select the Lindorm data source associated with the function.
Lindorm Database
Select the Lindorm database to which the function belongs. The default value is default.
Resource Group
Select the scheduling resource group used to perform the function registration operation.
Noteonly Serverless resource group is supported.
Owner
Select the owner of the function.
Class Name
Enter the fully qualified class name of the implementation class. For example,
com.example.udf.MyFunction.Resource List
Select the Lindorm File resource associated with the function from the drop-down list. The resource should contain the JAR package with the function implementation class.
Description
(Optional) Enter a description of the function to help other developers understand its purpose.
Command Format
(Optional) Enter the command format for calling the function. For example,
function_name(param1, param2).Parameter Description
(Optional) Enter a detailed description of the function parameters, including parameter names, types, and meanings.
Return Value
(Optional) Enter the return value description, including the return type and its meaning.
Example
(Optional) Enter a usage example of the function to help other developers quickly understand how to call the function and the expected results.
-
On the toolbar, Save and Deploy the function. Only deployed functions can be used in data development.
Use a function
After a function is created and deployed, you can use it during data development. When editing a node, click Resource Management in the left-side navigation pane, find the target function, and right-click to choose Use Function. The custom function name is generated in the current node editor. 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.
NoteFor 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.