This topic describes how to register an E-MapReduce (EMR) function.
Prerequisites
-
EMR engine types include DataLake and Hadoop. The required preparations vary by engine type. You must complete the necessary preparations in both EMR and DataWorks.
-
DataLake: For more information, see DataLake cluster configuration and DataWorks configuration.
-
-
You must upload resources before you can register a function. For more information about how to create an EMR resource, see Create and use EMR resources.
Procedure
-
Go to the DataStudio page.
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Development.
-
Create a workflow. For more information, see Create a scheduled workflow.
-
Write your program in a local Java environment, package it into a JAR file, and then create and submit a JAR resource. For more information, see Create and use EMR resources.
-
Create a function.
-
Open the workflow you want, right-click EMR, and select Create Function.
-
In the Create Function dialog box, enter a Name, and select an Engine Instance and a Path.
-
Click Create.
-
In the Register Function dialog box, configure the following parameters.
Parameter
Description
Function Type
Select a function type. Options include Mathematical Operation Functions, Aggregate Functions, String Processing Functions, Date Functions, Window Functions, and Other Functions.
EMR engine instance
A default value is displayed and cannot be changed.
EMR engine type
A default value is displayed and cannot be changed.
EMR database
Select a database from the drop-down list. To create a new database, click Create Database. In the Create Database dialog box, configure the parameters and click OK.
Function Name
The UDF name used in SQL statements. This name must be globally unique and cannot be changed after registration.
Owner
The owner is displayed by default.
Class Name
Required. The main class name that implements the UDF.
Resources
Required. From the drop-down list, select a resource that belongs to the current workspace. To create a resource, click Create Resource. In the Create Resource dialog box, configure the parameters and click Determine.
Description
A brief description of the UDF.
Expression Syntax
An example of how to use this UDF is
test.Parameter Description
The supported input and return parameter types.
Return Value
Optional. The return value, such as 1.
Example
Optional. A usage example.
-
-
Click the Save icon
in the toolbar. -
Submit the function.
-
Click the Submit icon
in the toolbar.NoteWhen you submit the function, you must select a scheduling resource group. We recommend using a serverless resource group. If you use a serverless resource group, DataWorks submits the function registration task to the EMR engine, which then runs the task and prints execution logs. If an error occurs during submission, you can use the logs for troubleshooting. If a serverless resource group is not available, you must purchase and configure one. For more information, see Use serverless resource groups.
-
In the Commit Node dialog box, enter a Change Description.
-
Click OK.
-