Creates a file for a function in DataStudio.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesCreateUdfFile

The operation that you want to perform. Set the value to CreateUdfFile.

FileFolderPathStringYesWorkflow/1/Function/String function

The path of the folder in which the file for the function is stored.

ProjectIdLongNo10000

The DataWorks workspace ID. You can click the Workspace Manage icon in the upper-right corner of the DataStudio page to go to the Workspace page and view the workspace ID.

FileNameStringYesStringConcat

The name of the function.

FunctionTypeStringYesSTRING

The type of the function. Valid values: MATH, AGGREGATE, STRING, DATE, ANALYTIC, and OTHER. This parameter corresponds to the Function Type parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ClassNameStringYescom.alibaba.DataWorks.api.udf.StringConcat

The name of the class in which the function is defined. This parameter corresponds to the Class Name parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ResourcesStringYesstring-concat-1.0.0.jar,commons-lang-2.6.jar

The names of the resources to be referenced by the function. This parameter corresponds to the Resources parameter in the Register Function section of the configuration tab of the function on the DataStudio page. Separate multiple resource names with commas (,).

UdfDescriptionStringYesNew string that is generated after multiple strings are concatenated

The description of the function. This parameter corresponds to the Description parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

CmdDescriptionStringNoStringConcat(String... substrs)

The syntax used for calling the function. This parameter corresponds to the Expression Syntax parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ParameterDescriptionStringNoStrings to be concatenated

The description of the input parameters of the function. This parameter corresponds to the Parameter Description parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ReturnValueStringNoNew string that is generated after all strings are concatenated in sequence

The description of the return value of the function. This parameter corresponds to the Return Value parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ExampleStringNoStringConcat('a', 'b', 'c')

The example for calling the function. This parameter corresponds to the Example parameter in the Register Function section of the configuration tab of the function on the DataStudio page.

ProjectIdentifierStringNodw_project

The unique identifier of the DataWorks workspace. You can click the identifier in the upper-left corner of the DataStudio page to switch to another workspace.

CreateFolderIfNotExistsBooleanNofalse

Specifies whether to automatically create the directory that is specified by the FileFolderPath parameter if the directory does not exist. Valid values:

true: Automatically create the directory if the directory does not exist.

false: Do not automatically create the directory if the directory does not exist. In this case, the call fails.

Response parameters

ParameterTypeExampleDescription
HttpStatusCodeInteger200

The HTTP status code.

DataLong100000002

The ID of the file that was created.

RequestIdString0000-ABCD-EFG****

The request ID. You can troubleshoot issues based on the ID.

ErrorMessageStringThe connection does not exist.

The error message.

SuccessBooleantrue

Indicates whether the request was successful.

ErrorCodeStringInvalid.Tenant.ConnectionNotExists

The error code.

Examples

Sample requests

http(s)://[Endpoint]/?Action=CreateUdfFile
&FileFolderPath=Workflow/1/Function/String function
&ProjectId=10000
&FileName=StringConcat
&FunctionType=STRING
&ClassName=com.alibaba.DataWorks.api.udf.StringConcat
&Resources=string-concat-1.0.0.jar,commons-lang-2.6.jar
&UdfDescription=New string that is generated after multiple strings are concatenated
&CmdDescription=StringConcat(String... substrs)
&ParameterDescription=Strings to be concatenated
&ReturnValue=New string that is generated after all strings are concatenated in sequence
&Example=StringConcat('a', 'b', 'c')
&ProjectIdentifier=dw_project
&CreateFolderIfNotExists=false
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<RequestId>0000-ABCD-EFG****</RequestId>
<HttpStatusCode>200</HttpStatusCode>
<Data>100000002</Data>
<Success>true</Success>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "0000-ABCD-EFG****",
  "HttpStatusCode" : 200,
  "Data" : 100000002,
  "Success" : true
}

Error codes

HttpCodeError codeError messageDescription
429Throttling.ApiThe request for this resource has exceeded your available limit.The number of requests for the resource has exceeded the upper limit.
429Throttling.SystemThe DataWorks system is busy. Try again later.The DataWorks system is busy. Try again later.
429Throttling.UserYour request is too frequent. Try again later.Excessive requests have been submitted within a short period of time. Try again later.
500InternalError.SystemAn internal system error occurred. Try again later.An internal error occurred. Try again later.
500InternalError.UserId.MissingAn internal system error occurred. Try again later.An internal error occurred. Try again later.

For a list of error codes, see Service error codes.