Operator Functions
This section describes operator functions, including their syntax, parameters, and usage examples.
Function List
If the value is negative, use the op_neg(positive value) function. For example, to indicate -1, use op_neg(1).
Type |
Function |
Description |
---|---|---|
Condition judgment |
Evaluates a condition and returns the value of one of two expressions based on the evaluation result. |
|
Returns the first expression value that is not None. |
||
Returns the first expression value that is not None. |
||
Returns None if expression1 is equal to expression2. Otherwise, it returns the value of expression1. |
||
Uses the logical operation and to check whether a value of any type is true or false. If all parameter values are true, true is returned. |
||
Uses the logical operation not to check whether a value of any type is true or false. It returns the Boolean opposite of the parameter value's true or false evaluation. |
||
Uses the logical operation or to check whether a value of any type is true or false. If any parameter value is true, true is returned. If all parameter values are false, false is returned. |
||
Comparison |
Calculates based on the a == b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
|
Calculates based on the a ≥ b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
||
Calculates based on the a > b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
||
Calculates based on the a ≤ b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
||
Calculates based on the a < b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
||
Calculates based on the a != b condition and returns true or false. The data types of a and b must be identical, for example, both strings, numbers, or lists. |
||
Container judgment |
Calculates the number of characters in a text string. It can be used for strings and other expressions that return tuples, lists, and dictionaries. |
|
Checks whether a string, tuple, list, or dictionary contains a specific element and returns true or false. |
||
Checks whether a string, tuple, list, or dictionary does not contain a specific element and returns true or false. |
||
Extracts a portion (slice) of a specified string, array, or tuple. |
||
Retrieves an element from a string, array, or tuple based on its specified index. |
||
General multi-value operations |
Calculates the sum of multiple values, which can be strings or digits. |
|
Calculates the maximum value of multiple fields or expressions. |
||
Calculates the minimum value of multiple fields or expressions. |
op_if
This function evaluates a condition and returns the value of one of two expressions based on the evaluation result.
- Function format
op_if(condition, expression1, expression2)
- Parameter description
Parameter
Type
Mandatory
Description
condition
Any
Yes
Condition to evaluate. If the condition is not a Boolean, the system determines whether it is true or false.
expression1
Any
Yes
Value of this expression returned when the condition evaluates to true.
expression2
Any
Yes
Value of this expression returned when the condition evaluates to false.
- Returned result
The value of the corresponding expression.
- Function example
- Example 1: If content is true, the value of expression1 is assigned to test_if.
- Test data
{ "content": "hello" }
- Processing rule
e_set("test_if", op_if(v("content"),"still origion content","replace this"))
- Processing result
content: hello test_if: still origion content
- Test data
- Example 2: If content is false, the value of expression2 is assigned to test_if.
- Test data
{ "content": 0 }
- Processing rule
e_set("test_if", op_if(ct_int(v("content", default=0)),"still origion content","replace this"))
- Processing result
content: 0 test_if: replace this
- Test data
- Example 1: If content is true, the value of expression1 is assigned to test_if.
op_ifnull
This function returns the first expression value that is not None.
- Function format
op_ifnull(expression1, expression2, ....)
- Parameter description
Parameter
Type
Mandatory
Description
expression1
Any
Yes
Expression 1.
expression2
Any
Yes
Expression 2.
- Returned result
The first expression value that is not None.
- Function example
- Example 1:
- Test data
{ "test_if": "hello", "escape_name": "Etl" }
- Processing rule
e_set("test_ifnull", op_ifnull(v("escape_name"),v("test_if")))
- Processing result
test_if: hello escape_name: Etl test_ifnull: Etl
- Test data
- Example 2:
- Test data
{ "test_if": "hello", "escape_name": "Etl" }
- Processing rule
e_set("test_ifnull", op_ifnull(v("test_if"),v("escape_name")))
- Processing result
test_if: hello escape_name: Etl test_ifnull: hello
- Test data
- Example 1:
op_coalesce
This function returns the first expression value that is not None.
- Function format
op_coalesce(expression1, expression2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
expression1
Any
Yes
Expression 1.
expression2
Any
Yes
Expression 2.
- Returned result
The first expression value that is not None.
- Function example
- Example 1:
- Test data
{ "test_if": "hello", "escape_name": "Etl" }
- Processing rule
e_set("test_coalesce", op_coalesce(v("escape_name"),v("test_if")))
- Processing result
test_if: hello escape_name: Etl test_coalesce: Etl
- Test data
- Example 2:
- Test data
{ "test_if": "hello", "escape_name": "Etl" }
- Processing rule
e_set("test_coalesce", op_coalesce(v("test_if"),v("escape_name")))
- Processing result
test_if: hello escape_name: Etl test_coalesce: hello
- Test data
- Example 1:
op_nullif
This function returns None if expression1 is equal to expression2. Otherwise, it returns the value of expression1.
- Function format
op_nullif(expression1, expression2)
- Parameter description
Parameter
Type
Mandatory
Description
expression1
Any
Yes
Expression 1.
expression2
Any
Yes
Expression 2.
- Returned result
Returns None if expression1 is equal to expression2. Otherwise, it returns the value of expression1.
- Function example
- Example 1:
- Test data
{ "test_if": "hello", "escape_name": "Etl" }
- Processing rule
e_set("test_ifnull", op_nullif(v("test_if"),v("escape_name")))
- Processing result
test_if: hello escape_name: Etl test_ifnull: hello
- Test data
- Example 2:
- Test data
{ "test_if": "hello", "escape_name": "hello" }
- Processing rule
e_set("test_ifnull", op_nullif(v("content"),v("escape_name")))
- Processing result
# Because the values of content and escape_name are the same, no content is returned for the test_isnull field. test_if: hello escape_name: hello
- Test data
- Example 1:
op_and
This function uses the logical operation and to check whether a value of any type is true or false. If all parameter values are true, true is returned.
- Function format
op_and(value1, value2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Any
Yes
Operation value 2.
- Returned result
- Returns true if all parameter values are true.
- Checks whether a value of any type is true or false.
- Function example
- Example 1:
- Test data
{ "number1": 123, "number2": 234 }
- Processing rule
e_set("op_and", op_and(v("number1"),v("number2")))
- Processing result
number1: 123 number2: 234 op_and: true
- Test data
- Example 2:
- Test data
{ "number1": 0, "number2": 234 }
- Processing rule
e_set("op_and", op_and(v("number1"),v("number2")))
- Processing result
number1: 0 number2: 234 op_and: false
- Test data
- Example 3:
- Test data
{ "ctx1": "false", "ctx2": 234 }
- Processing rule
e_set("op_and", op_and(v("ctx1"),v("ctx2")))
- Processing result
ctx1: false ctx2: 234 op_and: true
- Test data
- Example 4:
- Test data
{ "ctx1": "true", "ctx2": 234 }
- Processing rule
e_set("op_and", op_and(v("ctx1"),v("ctx2")))
- Processing result
ctx1: true ctx2: 234 op_and: true
- Test data
- Example 1:
op_not
This function uses the logical operation not to check whether a value of any type is true or false. It returns the Boolean opposite of the expression's true or false evaluation.
- Function format
op_not(expression)
- Parameter description
Parameter
Type
Mandatory
Description
expression
Any
Yes
Expression.
- Returned result
- Returns the Boolean value that is opposite to the expression value.
- Checks whether a value of any type is true or false.
- Function example
- Example 1:
- Test data
{ "ctx1": "true" }
- Processing rule
e_set("op_not", op_not(v("ctx1")))
- Processing result
ctx1: true op_not: false
- Test data
- Example 2:
- Test data
{ "ctx1": 345 }
- Processing rule
e_set("op_not", op_not(v("ctx1")))
- Processing result
ctx1: 345 op_not: false
- Test data
- Example 3:
- Test data
{ "ctx1": 0 }
- Processing rule
e_set("op_not", op_not(ct_int(v("ctx1"))))
- Processing result
ctx1: 0 op_not: true
- Test data
- Example 4:
- Test data
{ "ctx1": "ETL" }
- Processing rule
e_set("op_not", op_not(v("ctx1")))
- Processing result
ctx1: ETL op_not: false
- Test data
- Example 5:
- Test data
{ "ctx1": "None" }
- Processing rule
e_set("op_not", op_not(v("ctx1")))
- Processing result
ctx1: None op_not: false
- Test data
- Example 1:
op_or
This function uses the logical operation or to check whether a value of any type is true or false. If the value of any expression is true, true is returned. If the values of all expressions are false, false is returned.
- Function format
op_or(expression1, expression2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
expression1
Any
Yes
Expression 1.
expression2
Any
Yes
Expression 2.
- Returned result
- Returns true if the value of any expression is true, or returns false if the values of all expressions are false.
- Checks whether a value of any type is true or false.
- Function example
- Example 1:
- Test data
{ "ctx1": 123, "ctx2": 234 }
- Processing rule
e_set("op_or", op_or(v("ctx1"),v("ctx2")))
- Processing result
ctx1: 123 ctx2: 234 op_or: true
- Test data
- Example 2:
- Test data
{ "ctx1": 0, "ctx2": 234 }
- Processing rule
e_set("op_or", op_or(v("ctx1"),v("ctx2")))
- Processing result
ctx1: 0 ctx2: 234 op_or: true
- Test data
- Example 3:
- Test data
{ "ctx1": "ETL", "ctx2": "aa" }
- Processing rule
e_set("op_or", op_or(v("ctx1"),v("ctx2")))
- Processing result
ctx1: ETL ctx2: aa op_or: true
- Test data
- Example 4:
- Test data
{ "ctx1": "true", "ctx2":"false" }
- Processing rule
e_set("op_or", op_or(v("ctx1"),v("ctx2")))
- Processing result
ctx1: true ctx2: false op_or: true
- Test data
- Example 5:
- Test data
{ "ctx1": 0, "ctx2":"false" }
- Processing rule
e_set("op_or", op_or(ct_int(v("ctx1")),v("ctx2")))
- Processing result
ctx1: 0 ctx2: false op_or: true
- Test data
- Example 6:
- Test data
{ "ctx1": 124, "ctx2": "true" }
- Processing rule
e_set("op_or", op_or(v("ctx1"),v("ctx2")))
- Processing result
ctx1: 124 ctx2: true op_or: true
- Test data
- Example 1:
op_eq
This function calculates based on the a == b condition and returns true or false.
- Function format
op_eq(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is equal to value2. Otherwise, it returns false.
- Function example
- Example 1:
- Test data
{ "content": "hello", "ctx": "hello" }
- Processing rule
e_set("test_eq", op_eq(v("content"),v("ctx")))
- Processing result
content: hello ctx: hello test_eq: true
- Test data
- Example 2:
- Test data
{ "content": "hello", "ctx": "ctx" }
- Processing rule
e_set("test_eq", op_eq(v("content"),v("ctx")))
- Processing result
content: hello ctx: ctx test_eq: false
- Test data
- Example 1:
op_ge
This function calculates based on the a ≥ b condition and returns true or false.
- Function format
op_ge(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is greater than or equal to value2. Otherwise, it returns false.
- Function example
- Example 1: If the value of apple_price is greater than or equal to that of orange_price, true is returned.
- Test data
{ "apple_price": 16, "orange_price": 14 }
- Processing rule
e_set("test_ge", op_ge(ct_int(v("apple_price")),ct_int(v("orange_price"))))
- Processing result
apple_price: 16 orange_price: 14 test_ge: true
- Test data
- Example 2: If the value of apple_price is less than that of orange_price, false is returned.
- Test data
{ "apple_price": 12, "orange_price": 14 }
- Processing rule
e_set("test_ge", op_ge(ct_int(v("apple_price")),ct_int(v("orange_price"))))
- Processing result
apple_price: 12 orange_price: 14 test_ge: false
- Test data
- Example 1: If the value of apple_price is greater than or equal to that of orange_price, true is returned.
op_gt
This function calculates based on the a > b condition and returns true or false.
- Function format
op_gt(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is greater than value2. Otherwise, it returns false.
- Function example
- Example 1: Checks whether the value of old_number is greater than that of young_number. If yes, true is returned. If no, false is returned.
- Test data
{ "old_number": 16, "young_number": 14 }
- Processing rule
e_set("op_gt",op_gt(ct_int(v("old_number")),ct_int(v("young_number"))))
- Processing result
old_number: 16 young_number: 14 test_ge: true
- Test data
- Example 2: Checks whether the value of priority is greater than that of price. If yes, true is returned. If no, false is returned.
- Test data
{ "priority": 14, "price": 16 }
- Processing rule
e_set("op_gt",op_gt(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 14 price: 16 test_ge: false
- Test data
- Example 1: Checks whether the value of old_number is greater than that of young_number. If yes, true is returned. If no, false is returned.
op_le
This function calculates based on the a ≤ b condition and returns true or false.
- Function format
op_le(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is less than or equal to value2. Otherwise, it returns false.
- Function example
- Example 1: If the value of priority is less than or equal to that of price, true is returned. Otherwise, false is returned.
- Test data
{ "priority": 16, "price": 14 }
- Processing rule
e_set("op_le",op_le(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 16 price: 14 op_le: false
- Test data
- Example 2: If the value of priority is less than or equal to that of price, true is returned. Otherwise, false is returned.
- Test data
{ "priority": 14, "price": 16 }
- Processing rule
e_set("op_le",op_le(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 14 price: 16 test_ge: true
- Test data
- Example 1: If the value of priority is less than or equal to that of price, true is returned. Otherwise, false is returned.
op_lt
This function calculates based on the a < b condition and returns true or false.
- Function format
op_lt(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is less than value2. Otherwise, it returns false.
- Function example
- Example 1: If the value of priority is less than that of price, true is returned. Otherwise, false is returned.
- Test data
{ "priority": 16, "price": 14 }
- Processing rule
e_set("op_lt",op_lt(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 16 price: 14 op_lt: false
- Test data
- Example 2: If the value of priority is less than that of price, true is returned. Otherwise, false is returned.
- Test data
{ "priority": 14, "price": 15 }
- Processing rule
e_set("op_lt",op_lt(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 14 price: 15 op_lt: true
- Test data
- Example 1: If the value of priority is less than that of price, true is returned. Otherwise, false is returned.
op_ne
This function calculates based on the a != b condition and returns true or false.
- Function format
op_ne(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
Returns true if value1 is not equal to value2. Otherwise, it returns false.
- Function example
- Example 1:
- Test data
{ "priority": 16, "price": 14 }
- Processing rule
e_set("op_ne",op_ne(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 16 price: 14 op_ne: true
- Test data
- Example 2:
- Test data
{ "priority": 14, "price": 14 }
- Processing rule
e_set("op_ne",op_ne(ct_int(v("priority")),ct_int(v("price"))))
- Processing result
priority: 14 price: 14 op_ne: false
- Test data
- Example 1:
op_len
This function calculates the number of characters in a text string. It can be used for strings and other expressions that return tuples, lists, and dictionaries.
- Function format
op_len(value)
- Parameter description
Parameter
Type
Mandatory
Description
value
String, tuple, list, or dictionary
Yes
Operation value.
- Returned result
Returns the length of the field.
- Function example
- Test data
{ "content": "I,love,this,world" }
- Processing rule
e_set("op_len",op_len(v("content")))
- Processing result
content: I,love,this,world op_len: 17
- Test data
op_in
This function checks whether a string, tuple, list, or dictionary contains a specific element and returns true or false.
- Function format
op_in(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
String, tuple, list, or dictionary
Yes
String, tuple, list, or dictionary
value2
Any
Yes
Element to be checked.
Note: In this function, the string, tuple, list, or dictionary parameter is placed before the element.
- Returned result
Returns true if string, tuple, list, or dictionary a contains element b. Otherwise, it returns false.
- Function example
- Test data
{ "list": [1, 3, 2, 7, 4, 6], "num2": 2 }
- Processing rule
e_set("op_in",op_in(v("list"),v("num2")))
- Processing result
list: [1, 3, 2, 7, 4, 6] num2: 2 op_in: true
- Test data
op_not_in
This function checks whether a string, tuple, list, or dictionary does not contain a specific element and returns true or false.
- Function format
op_not_in(value1, value2)
- Parameter description
Parameter
Type
Mandatory
Description
value1
String, tuple, list, or dictionary
Yes
String, tuple, list, or dictionary
value2
Any
Yes
Element to be checked.
Note: In this function, the string, tuple, list, or dictionary parameter is placed before the element.
- Returned result
Returns true if the string, tuple, list, or dictionary does not contain the specified element. Otherwise, it returns false.
- Function example
- Test data
{ "list": [1, 3, 2, 7, 4, 6], "num2": 12 }
- Processing rule
e_set("op_not_in",op_not_in(v("list"),v("num2")))
- Processing result
list: [1, 3, 2, 7, 4, 6] num2: 12 op_not_in: true
- Test data
op_slice
This function extracts a portion (slice) of a specified string, array, or tuple.
- Function format
op_slice(value, start=0, end=None, step=None)
- Parameter description
Parameter
Type
Mandatory
Description
value
String
Yes
Value to be sliced.
start
Num
No
Start position of the slice. The default value is 0.
end
Num
No
End position of the slice (exclusive). The character/element at this position is excluded. It defaults to the end position of value.
step
Num
No
Length of each slice.
- Returned result
The extracted substring, sub-array, or sub-tuple.
- Function example
- Example 1: Truncate the word field from the start point to the end point 2.
- Test data
{ "word": "I,love,this,world" }
- Processing rule
e_set("op_slice",op_slice(v("word"),2))
- Processing result
word: I,love,this,world op_slice: I,
- Test data
- Example 2: Truncate the word field from position 2 to position 9 with a step length of 1.
- Test data
{ "word": "I,love,this,world" }
- Processing rule
e_set("op_slice",op_slice(v("word"),2,9,1))
- Processing result
word: I,love,this,world op_slice: love,th
- Test data
- Example 1: Truncate the word field from the start point to the end point 2.
op_index
This function retrieves an element from a string, array, or tuple based on its specified index.
- Function format
op_index(value, index)
- Parameter description
Parameter
Type
Mandatory
Description
value
String
Yes
String, array, tuple, etc.
index
Num
No
Index of the element you want to retrieve.
- Returned result
The element corresponding to the index.
- Function example
- Example 1: Retrieve the element at index 0 from the word field.
- Test data
{ "word": "I,love,this,world" }
- Processing rule
e_set("op_index",op_index(v("word"),0))
- Processing result
word: I,love,this,world op_index: I
- Test data
- Example 2: Retrieve the element at index 3 from the word field.
- Test data
{ "word": "I,love,this,world" }
- Processing rule
e_set("op_index",op_index(v("word"),3))
- Processing result
word: I,love,this,world op_index: o
- Test data
- Example 1: Retrieve the element at index 0 from the word field.
op_add
This function calculates the sum of multiple values, which can be strings or digits.
- Function format
op_add(value1, value2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
value1
String, tuple, list, or dictionary
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
The sum of the two values.
- Function example
- Example 1: Calculate the total amount of price_orange and price_apple.
- Test data
{ "price_orange": 2, "price_apple": 13 }
- Processing rule
e_set("account",op_add(ct_int(v("price_orange")),ct_int(v("price_apple"))))
- Processing result
price_orange: 2, price_apple: 13, account: 15
- Test data
- Example 2: Calculate the sum of bytes_in and bytes_out.
- Test data
{ "bytes_in": 214, "bytes_out": 123 }
- Processing rule
e_set("total_bytes", op_add(ct_int(v("bytes_in")), ct_int(v("bytes_out"))))
- Processing result
bytes_in: 214 bytes_out: 123 total_bytes: 337
- Test data
- Example 3: Add the HTTPS header to the website.
- Test data
{ "host": "xx.com" }
- Processing rule
e_set("website", op_add("https://", v("host")))
- Processing result
host: xx.com website: https://xx.com
- Test data
- Example 1: Calculate the total amount of price_orange and price_apple.
op_max
This function calculates the maximum value of multiple fields or expressions.
- Function format
op_max(value1, value2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
The maximum value among multiple values.
- Function example
- Test data
{ "price_orange": 2, "priority_apple": 13 }
- Processing rule
e_set("max_price", op_max(ct_int(v("price_orange")),ct_int(v("priority_apple"))))
- Processing result
price_orange: 2 priority_apple: 13 max_price: 13
- Test data
op_min
This function calculates the minimum value of multiple fields or expressions.
- Function format
op_min(value1, value2, ...)
- Parameter description
Parameter
Type
Mandatory
Description
value1
Any
Yes
Operation value 1.
value2
Same as value1's type
Yes
Operation value 2.
- Returned result
The minimum value among multiple values.
- Function example
- Test data
{ "price_orange": 2, "priority_apple": 13 }
- Processing rule
e_set("op_min", op_min(ct_int(v("price_orange")),ct_int(v("priority_apple"))))
- Processing result
price_orange: 2 priority_apple: 13 op_min: 2
- Test data
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot