This topic describes the syntax and parameters of operator functions. This topic also provides examples on how to use the functions.

Note If you want to obtain a negative value, use the op_neg (positive value) function. For example, use op_neg(1) to return `-1`.

## Functions

Type Function Description
Conditional functions and logical functions op_if Returns an expression based on a specified condition.
op_ifnull and op_coalesce Returns the value of the first expression whose value is not None.
op_nullif Returns the value None if the value of Expression 1 is equal to the value of Expression 2. Otherwise, the value of Expression 1 is returned.
op_and Returns a Boolean value after the AND operator computes the logical AND of two or more specified fields. Each field can be of an arbitrary data type.
op_not Returns a Boolean value after the NOT operator computes logical negation of a specified field. The field can be of an arbitrary data type.
op_or Returns a Boolean value after the OR operator computes the logical OR of two or more specified fields. Each field can be of an arbitrary data type.
Comparison functions op_eq Returns the result that is calculated based on the `a==b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

op_ge Returns the result that is calculated based on the `a>=b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

op_gt Returns the result that is calculated based on the `a>b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

op_le Returns the result that is calculated based on the `a<=b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

op_lt Returns the result that is calculated based on the `a<b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

op_ne Returns the result that is calculated based on the `a!=b` condition.

The data types of a and b must be the same. For example, a and b are both strings, numbers, or lists.

Container functions op_len Calculates the number of characters in a text string. You can use this function in expressions that return strings, tuples, lists, or dictionaries.
op_in Checks whether a string, tuple, list, or dictionary contains a specified element.
op_not_in Checks whether a string, tuple, list, or dictionary does not contain a specified element.
op_slice Truncates a specified string, array, or tuple.
op_index Returns the element that corresponds to the index of a specified string, array, or tuple.
General-purpose multivalued functions op_add Calculates the sum of multiple values. The values can be strings or numbers.
op_max Returns the maximum value among the values of multiple fields or expressions.
op_min Returns the minimum value among the values of multiple fields or expressions.

## op_if

• Syntax
``op_if(Condition,Value 1,Value 2)``
• Parameters
Parameter Type Required Description
Condition Arbitrary Yes A condition. If the value of the condition is not a Boolean value, the system evaluates whether the condition is true or false. For more information, see True or false evaluation.
Value 1 Arbitrary Yes Expression 1 that is returned if the specified condition is evaluated to True.
Value 2 Arbitrary Yes Expression 2 that is returned if the specified condition is evaluated to False.
• Response

The expression that corresponds to the evaluation result of the specified condition is returned.

• Examples
• Example 1: If the value of the `content` field is True, the value of Expression 1 is aspecified for the `test_if` field.
Raw log entry:
``content: hello``
Transformation rule:
``e_set("test_if", op_if(v("content"),"still origion content","replace this"))``
Result:
``````content: hello
test_if:  still origion content``````
• Example 2: If the value of the `content` field is false, the value of Expression 2 is assigned to the `test_if` field.
Raw log entry:
``content: 0``
Transformation rule:
``e_set("test_if", op_if(ct_int(v("content", default=0)),"still origion content","replace this"))``
Result:
``````content: 0
test_if:  replace this``````

## op_ifnull

• Syntax
``op_ifnull(Value 1,Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of the expression that you want to return.
Value 2 Arbitrary Yes The value of the expression that you want to return.
• Response

The value of the first expression whose value is not None is returned.

• Examples
• Example 1
Raw log entry:
``````test_if: hello
escape_name: Etl``````
Transformation rule:
``e_set("test_ifnull", op_ifnull(v("escape_name"),v("test_if")))``
Result:
``````test_if: hello
escape_name: Etl
test_ifnull:  Etl``````
• Example 2
Raw log entry:
``````test_if: hello
escape_name: Etl``````
Transformation rule:
``e_set("test_ifnull", op_ifnull(v("test_if"),v("escape_name")))``
Result:
``````test_if: hello
escape_name: Etl
test_ifnull:  hello``````

## op_coalesce

The parameters and examples of the op_coalesce function are similar to the parameters and examples of the `op_ifnull` function. For more information, see op_ifnull.

## op_nullif

• Syntax
``op_nullif(Value 1,Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Arbitrary Yes The value of a field.
• Response

If Value 1 is equal to Value 2, the value None is returned. Otherwise, Value 1 is returned.

• Examples
• Example 1
Raw log entry:
``````content: hello
escape_name: Etl``````
Transformation rule:
``e_set("test_ifnull", op_nullif(v("content"),v("escape_name")))``
Result:
``````content: hello
escape_name: Etl
test_nullif:  hello``````
• Example 2
Raw log entry:
``````content: hello
escape_name: hello``````
Transformation rule:
``e_set("test_ifnull", op_nullif(v("content"),v("escape_name")))``
Result:
``````content: hello
escape_name: hello
# In this example, the value of the content field is the same as the value of the escape_name field. Therefore, the value None is returned. This indicates that no content is assigned to the test_isnull field. ``````

## op_and

• Syntax
``op_and(Value 1,Value 2, ...)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The field value on which you want to perform the AND operation.
Value 2 Arbitrary Yes The field value on which you want to perform the AND operation.
• Response
• If all specified fields are evaluated to true, the value True is returned.
• The system evaluates all types of fields to true or false. For more information, see True or false evaluation.
• Examples
• Example 1
Raw log entry:
``````number1: 123
number2: 234``````
Transformation rule:
``e_set("op_and", op_and(v("number1"),v("number2")))``
Result:
``````number1: 123
number2: 234
op_and:  True``````
• Example 2
Raw log entry:
``````number1: 0
number2: 234``````
Transformation rule:
``e_set("op_and", op_and(v("number1"),v("number2")))``
Result:
``````number1: 0
number2: 234
op_and: True``````
• Example 3
Raw log entry:
``````ctx1: False
ctx2: 234``````
Transformation rule:
``e_set("op_and", op_and(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: False
ctx2: 234
op_and: False``````
• Example 4
Raw log entry:
``````ctx1: True
ctx2: 234``````
Transformation rule:
``````
e_set("op_and", op_and(v("ctx1"),v("ctx2")))``````
Result:
``````ctx1: True
ctx2: 234
op_and: True``````

## op_not

• Syntax
``op_not(Value)``
• Parameters
Parameter Type Required Description
Value Arbitrary Yes The field value on which you want to perform the NOT operation.
• Response
• The value True or False is returned.
• The system evaluates all types of fields to true or false. For more information, see True or false evaluation.
• Examples
• Example 1
Raw log entry:
``ctx1: True``
Transformation rule:
``e_set("op_not", op_not(v("ctx1")))``
Result:
``````ctx1: True
op_not:  False``````
• Example 2
Raw log entry:
``ctx1: 345``
Transformation rule:
``e_set("op_not", op_not(v("ctx1")))``
Result:
``````ctx1: 345
op_not:  False``````
• Example 3
Raw log entry:
``ctx1: 0``
Transformation rule:
``e_set("op_not", op_not(ct_int(v("ctx1"))))``
Result:
``````ctx1: 0
op_not:  True``````
• Example 4
Raw log entry:
``ctx1: ETL``
Transformation rule:
``e_set("op_not", op_not(v("ctx1")))``
Result:
``````ctx1: ETL
op_not:  False``````
• Example 5
Raw log entry:
``ctx1: None``
Transformation rule:
``e_set("op_not", op_not(v("ctx1")))``
Result:
``````ctx1: None
op_not:  True``````

## op_or

• Syntax
``op_or(Value 1, Value 2, ...Variable...)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The field value on which you want to perform the OR operation.
Value 2 Arbitrary Yes The field value on which you want to perform the OR operation.
• Response
• If one or more of the specified fields are evaluated to true, the value True is returned. Otherwise, the value False is returned.
• The system evaluates all types of fields to true or false. For more information, see True or false evaluation.
• Examples
• Example 1
Raw log entry:
``````ctx1: 123
ctx2: 234``````
Transformation rule:
``e_set("op_or", op_or(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: 123
ctx2: 234
op_or:  True``````
• Example 2
Raw log entry:
``````ctx1: 0
ctx2: 234``````
Transformation rule:
``e_set("op_or", op_or(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: 0
ctx2: 234
op_or:  True``````
• Example 3
Raw log entry:
``````ctx1: ETL
ctx2: ALIYUN``````
Transformation rule:
``e_set("op_or", op_or(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: ETL
ctx2: ALIYUN
op_or:  True``````
• Example 4
Raw log entry:
``````ctx1: True
ctx2: False``````
Transformation rule:
``e_set("op_or", op_or(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: True
ctx2: False
op_or:  True``````
• Example 5
Raw log entry:
``````ctx1: 0
ctx2: False``````
Transformation rule:
``e_set("op_or", op_or(ct_int(v("ctx1")),v("ctx2")))``
Result:
``````ctx1: 0
ctx2: False
op_or:  False``````
• Example 6
Raw log entry:
``````ctx1: 124
ctx2: True``````
Transformation rule:
``e_set("op_or", op_or(v("ctx1"),v("ctx2")))``
Result:
``````ctx1: 124
ctx2: True
op_or:  True``````

## op_eq

• Syntax
``op_eq(Value 1,Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is equal to Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1
Raw log entry:
``````content: hello
ctx: hello``````
Transformation rule:
``e_set("test_eq", op_eq(v("content"),v("ctx")))``
Result:
``````content: hello
ctx: hello
test_eq: True``````
• Example 2
Raw log entry:
``````content: hello
ctx: ctx``````
Transformation rule:
``e_set("test_eq", op_eq(v("content"),v("ctx")))``
Result:
``````content: hello
ctx: ctx
test_eq: False``````

## op_ge

• Syntax
``op_ge(Value 1, Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is greater than or equal to Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1: If the value of the apple_price field is greater than or equal to the value of the orange_price field, the value True is returned.
Raw log entry:
``````apple_price: 16
orange_price: 14``````
Transformation rule:
``e_set("test_ge", op_ge(ct_int(v("apple_price")),ct_int(v("orange_price"))))``
Result:
``````apple_price: 16
orange_price: 14
test_ge: true``````
• Example 2: If the value of the apple_price field is less than the value of the orange_price field, the value False is returned.
Raw log entry:
``````apple_price: 12
orange_price: 14``````
Transformation rule:
``e_set("test_ge", op_ge(ct_int(v("apple_price")),ct_int(v("orange_price"))))``
Result:
``````apple_price: 12
orange_price: 14
test_ge: false``````

## op_gt

• Syntax
``op_gt(Value 1, Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is greater than Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1: If the value of the old_number field is greater than the value of the young_number field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````old_number: 16
young_number: 14``````
Transformation rule:
``e_set("op_gt",op_gt(ct_int(v("old_number")),ct_int(v("young_number"))))``
Result:
``````old_number: 16
young_number: 14
test_ge: True``````
• Example 2: If the value of the priority field is greater than the value of the price field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````priority: 14
price: 16``````
Transformation rule:
``e_set("op_gt",op_gt(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 14
price: 16
test_ge: False``````

## op_le

• Syntax
``op_le(Value 1, Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is less than or equal to Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1: If the value of the priority field is less than or equal to the value of the price field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````priority: 16
price: 14``````
Transformation rule:
``e_set("op_le",op_le(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 16
price: 14
test_ge: False``````
• Example 2: If the value of the priority field is less than or equal to the value of the price field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````priority: 14
price: 16``````
Transformation rule:
``e_set("op_le",op_le(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 14
price: 16
test_ge: True``````

## op_lt

• Syntax
``op_lt(Value 1, Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is less than Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1: If the value of the priority field is less than the value of the price field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````priority: 16
price: 14``````
Transformation rule:
``e_set("op_lt",op_lt(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 16
price: 14
op_lt: False``````
• Example 2: If the value of the priority field is less than the value of the price field, the value True is returned. Otherwise, the value False is returned.
Raw log entry:
``````priority: 14
price: 15``````
Transformation rule:
``e_set("op_lt",op_lt(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 14
price: 15
op_lt: True``````

## op_ne

• Syntax
``op_ne(Value 1, Value 2)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

If Value 1 is not equal to Value 2, the value True is returned. Otherwise, the value False is returned.

• Examples
• Example 1
Raw log entry:
``````priority: 16
price: 14``````
Transformation rule:
``e_set("op_ne",op_ne(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 16
price: 14
op_ne: True``````
• Example 2
Raw log entry:
``````priority: 14
price: 14``````
Transformation rule:
``e_set("op_ne",op_ne(ct_int(v("priority")),ct_int(v("price"))))``
Result:
``````priority: 14
price: 14
op_ne: False``````

## op_len

• Syntax
``op_len(Value)``
• Parameters
Parameter Type Required Description
Value String, tuple, list, or dictionary Yes The field value whose length you want to calculate.
• Response

The length of the specified field value is returned.

• Example
Raw log entry:
``content: I,love,this,world``
Transformation rule:
``e_set("op_len",op_len(v("content")))``
Result:
``````content: I,love,this,world
op_len: 17``````

## op_in

• Syntax
``op_in(a, b)``
• Parameters
Parameter Type Required Description
a String, tuple, list, or dictionary Yes The name of a container.
b Arbitrary Yes The name of an element.
Note In this function, the a parameter that specifies a container precedes the b parameter that specifies an element.
• Response

If the container a contains the element b, the value True is returned. Otherwise, the value False is returned.

• Example
Raw log entry:
``````list:  [1, 3, 2, 7, 4, 6]
num2:  2``````
Transformation rule:
``e_set("op_in",op_in(v("list"),v("num2")))``
Result:
``````list:  [1, 3, 2, 7, 4, 6]
num2:  2
op_in: True``````

## op_not_in

• Syntax
``op_not_in(Container, Element)``
• Parameters
Parameter Type Required Description
Container String, tuple, list, or dictionary Yes The name of a container. The value of this parameter can be a string, tuple, list, or dictionary.
Element Arbitrary Yes The name of an element.
Note In this function, the a parameter that specifies a container precedes the b parameter that specifies an element
• Response

If the specified container does not contain the specified element, the value True is returned. Otherwise, the value False is returned.

• Example
Raw log entry:
``````list:  [1, 3, 2, 7, 4, 6]
num2:  12``````
Transformation rule:
``e_set("op_not_in",op_not_in(v("list"),v("num2")))``
Result:
``````list:  [1, 3, 2, 7, 4, 6]
num2:  12
op_in: True``````

## op_slice

• Syntax
``op_slice(Value, start=None, end=None, step)``
• Parameters
Parameter Type Required Description
Value String Yes The field value that you want to truncate.
start Num No The position from which the value of the specified field is truncated. Default value: 0.
end Num No The position to which the value of the specified field is truncated. The character in this position is not truncated. The position ends at the end of the specified string by default.
step Num No The number of characters that you want to truncate each time.
• Response

The substrings that are truncated from the value of the specified field are returned.

• Examples
• Example 1: The value of the word field is truncated from the start to the end at a step of 2.
Raw log entry:
``word:  I,love,this,world``
Transformation rule:
``e_set("op_slice",op_slice(v("word"),2))``
Result:
``````word:  I,love,this,world
op_slice: I,``````
• Example 2: The value of the word field is truncated from position 2 to position 9 at a step of 1.
Raw log entry:
``word:  I,love,this,world``
Transformation rule:
``e_set("op_slice",op_slice(v("word"),2,9,1))``
Result:
``````word:  I,love,this,world
op_slice: love,th``````

## op_index

• Syntax
``op_index (Value, index)``
• Parameters
Parameter Type Required Description
Value String Yes The field value that you want to truncate.
index Num No The index of the specified string, array, or tuple.
• Response

The element that corresponds to the index is returned.

• Examples
• Example 1: The element whose index is 0 in the value of the word field is returned.
Raw log entry:
``word:  I,love,this,world``
Transformation rule:
``e_set("op_index",op_index(v("word"),0))``
Result:
``````word:  I,love,this,world
op_slice: I,``````
• Example 2: The element whose index is 3 in the value of the word field is returned.
Raw log entry:
``word:  I,love,this,world``
Transformation rule:
``e_set("op_index",op_index(v("word"),3))``
Result:
``````word:  I,love,this,world
op_index: o``````

• Syntax
``op_add(Value 1, Value 2, ...)``
• Parameters
Parameter Type Required Description
Value 1 String, tuple, list, or dictionary Yes The field value on which you want to perform the ADD operation.
Value 2 Same as the data type of Value 1 Yes The field value on which you want to perform the ADD operation.
• Response

The sum of the specified values is returned.

• Examples
• Example 1: Calculate the sum of the values of the price_orange and price_apple fields to obtain the total price.
Raw log entry:
``````price_orange: 2
price_apple: 13``````
Transformation rule:
``e_set("account",op_add(ct_int(v("price_orange")),ct_int(v("price_apple"))))``
Result:
``````price_orange: 2
price_apple: 13
account:  15``````
• Example 2: Calculate the sum of the values of the bytes_in and bytes_out fields to obtain the total number of bytes.
Raw log entry:
``````bytes_in: 214
bytes_out: 123``````
Transformation rule:
``e_set("total_bytes", op_add(ct_int(v("bytes_in"), ct_int(v("bytes_out")))))``
Result:
``````bytes_in: 214
bytes_out: 123
total_bytes:  337``````
• Example 3: Add the https:// prefix to a website URL.
Raw log entry:
``host: aliyun.com``
Transformation rule:
``e_set("website", op_add("https://", v("host")))``
Result:
``````host: aliyun.com
website: https://aliyun.com``````

## op_max

• Syntax
``op_max(Value 1, Value 2, ...)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

The maximum value among the specified values is returned.

• Example
Raw log entry:
``````price_orange:  2
priority_apple:  13``````
Transformation rule:
``e_set("max_price", op_max(ct_int(v("price_orange")),ct_int(v("priority_apple"))))``
Result:
``````price_orange:  2
priority_apple:  13
max_price:  13``````

## op_min

• Syntax
``op_min(Value 1, Value 2, ...)``
• Parameters
Parameter Type Required Description
Value 1 Arbitrary Yes The value of a field.
Value 2 Same as the data type of Value 1 Yes The value of a field.
• Response

The minimum value among the specified values is returned.

• Example
Raw log entry:
``````price_orange:  2
price_apple:  13``````
Transformation rule:
``e_set("op_min", op_min(ct_int(v("price_orange")),ct_int(v("price_apple"))))``
Result:
``````price_orange:  2
price_apple:  13
op_min:  2``````