All Products
Search
Document Center

CloudFlow:Built-in functions

Last Updated:Jul 05, 2024

The flow definition language (FDL) of CloudFlow provides built-in functions that you can use to perform basic data processing operations. This topic describes the common built-in functions of CloudFlow.

Indexes

In the FDL of CloudFlow, built-in functions are divided into the following categories based on the type of data processing tasks.

Note

If you want to use built-in functions when you construct inputs and outputs, you must suffix .$ to the key of the constructor supported by the FDL to indicate that the corresponding value is an expression. The expression must be parsed. If you do not suffix .$ to the key of the constructor, the value is processed as a string. A maximum of 10 layers of nested built-in functions are supported in input and output construction.

Built-in functions

The following sections describe the built-in functions of CloudFlow. You can directly use the built-in functions.

arrayContains

Description: Determines whether an array contains a specific element.

Parameter description:

[]any

Return value:

bool

Usage example:

arrayContains(["Tom",10],10)
arrayContains(["Tom",10],"Jack")

Output example:

true
false

arrayUnique

Description: Deletes duplicate elements in an array.

Parameter description:

[]any

Return value:

[]any

Usage example:

arrayUnique([1, 2, 3, 1])

Output example:

[1, 2, 3]

format

Description: Uses the {} placeholder syntax for formatting.

Parameter description:

string, ...any
template, parameter list

Return value:

string

Usage example:

format("hello {}","world")

Output example:

"hello world"

fromBase64

Description: Decodes Base64-encoded strings.

Parameter description:

string

Return value:

string

Usage example:

fromBase64("Rm5G")

Output example:

"FnF"

stringToJson

Introduction: Converts a JSON string to a JSON object or map.

Parameter description:

string

Return value:

map[string]any

Usage example:

fromJSON('{"name": "Tom", "age": 10}')

Output example:

{"name": "Tom", "age": 10}

hash

Description: Uses specific algorithms to generate hash values of inputs.

Parameter description:

string,string
input, algorithm
    MD5
    SHA-1
    SHA-256
    SHA-512

Return value:

string

Usage example:

hash("abc","MD5")

Output example:

"900150983cd24fb0d6963f7d28e17f72"

jsonMerge

Introduction: Combines two JSON objects or maps.

Parameter description:

map[string]any,map[string]any

Return value:

map[string]any

Usage example:

jsonMerge({"name": "Tom", "age": 10},{"name": "Tom", "address": "beijing"})

Output example:

{"name": "Tom", "age": 10, "address": "beijing"}

length

Description: Obtains the length of an array, map, and string.

Parameter description:

[]any
map[string]any
string

Return value:

int

Usage example:

length([1, 2, 3])
length({"name": "Tom", "age": 10})
length("name") 

Output example:

3
2
4

mapKeys

Description: Extracts keys from JSON objects or maps to form the keys into an array.

Parameter description:

map[string]any

Return value:

[]string

Usage example:

mapKeys({"name": "Tom", "age": 10})

Output example:

["name","age"]

mapValues

Introduction: Extracts values from JSON objects or maps to form the values into an array.

Parameter description:

map[string]any

Return value:

[]any

Usage example:

mapValues({"name": "Tom", "age": 10})

Output example:

["Tom",10]

mapValuesPartition

Description: Extracts values from JSON objects or maps and splits the values into multiple arrays by a specific step.

Parameter description:

map[string]any

Return value:

[][]any

Usage example:

mapValuesPartition({"name": "Tom", "age": 10},1)

Output example:

["Tom"],[10]

regexMatchString

Description: Matches string functions based on simple regular expressions.

Parameter description:

string, string
expression, values to be matched

Return value:

bool

Usage example:

regexMatchString("p([a-z]+)ch", "peach")
regexMatchString("p([a-z]+)ch", "p123ch")

Output example:

true
false

split

Description: Splits strings based on specific delimiters.

Parameter description:

string,string

Return value:

[]string

Usage example:

split("item1,item2,item3", ",") 

Output example:

["item1", "item2", "item3"]

toArray

Description: Converts input parameters of any length into an array and returns the array.

Parameter description:

any

Return value:

[]any

Usage example:

toArray(1,'strig',$Input.var)

Output example:

[]any{1, 'string', $valueOfVar}

toBase64

Description: Encodes strings into the Base64 format.

Parameter description:

string

Return value:

string

Usage example:

toBase64("FnF")

Output example:

"Rm5G"

jsonToString

Description: Converts a JSON object or map to a string.

Parameter description:

map[string]any

Return value:

string

Usage example:

toJSON({"name": "Tom", "age": 10})

Output example:

'{"name": "Tom", "age": 10}'

uuid

Description: Generates a UUID.

Parameter description:

Return value:

string

Usage example:

uuid()

Output example:

159fd8c1-2ec3-4d7b-b9fd-60b9d8841000