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

## Functions

Note If you want to specify a negative value, you must use the `op_neg(positive value)` function. For example, if you want to specify the value `-1`, you must use op_neg(1).
Category Function Description
Conditional functions and logical functions op_if Returns the value of 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 None if the value of Expression 1 is equal to the value of Expression 2, or returns the value of Expression 1 if the value of Expression 1 is not equal to the value of Expression 2.
op_and Evaluates the specified expressions by using the logical AND operator and returns True if all specified expressions evaluate to true. The values of the expressions can be of any type.
op_not Evaluates a specified expression by using the logical NOT operator and returns the inverse Boolean value of the specified expression. The value of the expression can be of any type.
op_or Evaluates the specified expressions by using the logical OR operator, and returns True if a specified expression evaluates to true or returns False if all specified expressions evaluate to false. The values of the expressions can be of any type.
Comparison functions op_eq Returns True or False 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 True or False 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 True or False 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 True or False 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 True or False 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 True or False 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 strings and expressions that return tuples, lists, or dictionaries.
op_in Checks whether a string, tuple, list, or dictionary contains a specified element and returns True or False.
op_not_in Checks whether a string, tuple, list, or dictionary does not contain a specified element and returns True or False.
op_slice Extracts strings from 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 largest value among the values of multiple fields or expressions.
op_min Returns the smallest value among the values of multiple fields or expressions.

## op_if

The op_if function returns the value of an expression based on a specified condition.
• ### Syntax

``op_if(condition, expression1, expression12)``
• ### Parameters

Parameter Type Required Description
condition Arbitrary Yes The 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.
expression1 Arbitrary Yes The expression whose value is returned if the condition is True.
expression2 Arbitrary Yes The expression whose value is returned if the condition is False.
• ### Response

The value of an expression is returned.

• ### Examples

• Example 1: If the value of the `content` field evaluates to True, assign the value of Expression 1 to the `test_if` field.
• Raw log
``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 evaluates to False, assign the value of Expression 2 to the `test_if` field.
• Raw log
``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

The op_ifnull function returns the value of the first expression whose value is not None.
• ### Syntax

``op_ifnull(expression1, expression2, ....)``
• ### Parameters

Parameter Type Required Description
expression1 Arbitrary Yes Expression 1
expression2 Arbitrary Yes Expression 2
• ### Response

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

• ### Examples

• Example 1:
• Raw log
``````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
``````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 op_coalesce function returns the value of the first expression whose value is not None.

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

The op_nullif function returns None if the value of Expression 1 is equal to the value of Expression 2, or returns the value of Expression 1 if the value of Expression 1 is not equal to the value of Expression 2.
• ### Syntax

``op_nullif(expression1, expression2)``
• ### Parameters

Parameter Type Required Description
expression1 Arbitrary Yes Expression 1
expression2 Arbitrary Yes Expression 2
• ### Response

None is returned if the value of Expression 1 is equal to the value of Expression 2. The value of Expression 1 is returned if the value of Expression 1 is not equal to the value of Expression 2.

• ### Examples

• Example 1:
• Raw log
``````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
``````content: hello
escape_name: hello``````
• Transformation rule
``e_set("test_ifnull", op_nullif(v("content"),v("escape_name")))``
• Result
``````# In this example, the value of the content field is the same as the value of the escape_name field. Therefore, no value is assigned to the test_isnull field.
content: hello
escape_name: hello``````

## op_and

The op_and function evaluates the specified expressions by using the logical AND operator and returns True if all specified expressions evaluate to true. The values of the expressions can be of any type.
• ### Syntax

``op_and(value1, value2, ...)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Arbitrary Yes Value 2
• ### Response

• True is returned if all specified expressions evaluate to true.
• The values of the expressions can be of any type. For more information, see True or false evaluation.
• ### Examples

• Example 1:
• Raw log
``````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
``````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
``````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
``````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

The op_not function evaluates a specified expression by using the logical NOT operator and returns the inverse Boolean value of the specified expression. The value of the expression can be of any type.
• ### Syntax

``op_not(expression)``
• ### Parameters

Parameter Type Required Description
expression Arbitrary Yes The expression.
• ### Response

• The inverse Boolean value of the specified expression is returned.
• The value of the expression can be of any type. For more information, see True or false evaluation.
• ### Examples

• Example 1:
• Raw log
``ctx1: True``
• Transformation rule
``e_set("op_not", op_not(v("ctx1")))``
• Result
``````ctx1: True
op_not:  False``````
• Example 2:
• Raw log
``ctx1: 345``
• Transformation rule
``e_set("op_not", op_not(v("ctx1")))``
• Result
``````ctx1: 345
op_not:  False``````
• Example 3:
• Raw log
``ctx1: 0``
• Transformation rule
``e_set("op_not", op_not(ct_int(v("ctx1"))))``
• Result
``````ctx1: 0
op_not:  True``````
• Example 4:
• Raw log
``ctx1: ETL``
• Transformation rule
``e_set("op_not", op_not(v("ctx1")))``
• Result
``````ctx1: ETL
op_not:  False``````
• Example 5:
• Raw log
``ctx1: None``
• Transformation rule
``e_set("op_not", op_not(v("ctx1")))``
• Result
``````ctx1: None
op_not:  True``````

## op_or

The op_or function evaluates the specified expressions by using the logical OR operator, and returns True if a specified expression evaluates to true or returns False if all specified expressions evaluate to false. The values of the expressions can be of any type.
• ### Syntax

``op_or(expression1, expression2, ...)``
• ### Parameters

Parameter Type Required Description
expression1 Arbitrary Yes Expression 1
expression2 Arbitrary Yes Expression 2
• ### Response

• True is returned if a specified expression evaluates to true. False is returned if all specified expressions evaluate to false.
• The values of the expressions can be of any type. For more information, see True or false evaluation.
• ### Examples

• Example 1:
• Raw log
``````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
``````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
``````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
``````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
``````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
``````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

The op_eq function returns True or False based on the `a==b` condition.
• ### Syntax

``op_eq(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

True is returned if the value of Value 1 is equal to the value of Value 2. False is returned if the value of Value 1 is not equal to the value of Value 2.

• ### Examples

• Example 1:
• Raw log
``````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
``````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

The op_ge function returns True or False based on the `a>=b` condition.
• ### Syntax

``op_ge(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

True is returned if the value of Value 1 is greater than or equal to the value of Value 2. False is returned if the value of Value 1 is less than the value of Value 2.

• ### Examples

• Example 1: Return True if the value of the apple_price field is greater than or equal to the value of the orange_price field.
• Raw log
``````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: Return False if the value of the apple_price field is less than the value of the orange_price field.
• Raw log
``````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

The op_gt function returns True or False based on the `a>b` condition.
• ### Syntax

``op_gt(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1. Yes Value 2
• ### Response

True is returned if the value of Value 1 is greater than the value of Value 2. False is returned if the value of Value 1 is less than or equal to the value of Value 2.

• ### Examples

• Example 1: Return True if the value of the old_number field is greater than the value of the young_number field. Return False if the value of the old_number field is less than or equal to the value of the young_number field.
• Raw log
``````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: Return True if the value of the priority field is greater than the value of the price field. Return False if the value of the priority field is less than or equal to the value of the price field.
• Raw log
``````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

The op_le function returns True or False based on the `a<=b` condition.
• ### Syntax

``op_le(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

True is returned if the value of Value 1 is less than or equal to the value of Value 2. False is returned if the value of Value 1 is greater than the value of Value 2.

• ### Examples

• Example 1: Return True if the value of the priority field is less than or equal to the value of the price field. Return False if the value of the priority field is greater than the value of the price field.
• Raw log
``````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: Return True if the value of the priority field is less than or equal to the value of the price field. Return False if the value of the priority field is greater than the value of the price field.
• Raw log
``````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

The op_lt function returns True or False based on the `a<b` condition.
• ### Syntax

``op_lt(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

True is returned if the value of Value 1 is less than the value of Value 2. False is returned if the value of Value 1 is greater than or equal to the value of Value 2.

• ### Examples

• Example 1: Return True if the value of the priority field is less than the value of the price field. Return False if the value of the priority field is greater than or equal to the value of the price field.
• Raw log
``````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: Return True if the value of the priority field is less than the value of the price field. Return False if the value of the priority field is greater than or equal to the value of the price field.
• Raw log
``````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

The op_ne function returns True or False based on the `a!=b` condition.
• ### Syntax

``op_ne(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

True is returned if the value of Value 1 is not equal to the value of Value 2. False is returned if the value of Value 1 is equal to the value of Value 2.

• ### Examples

• Example 1:
• Raw log
``````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
``````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

The op_len function calculates the number of characters in a text string. You can use this function in strings and expressions that return tuples, lists, or dictionaries.
• ### Syntax

``op_len(value)``
• ### Parameters

Parameter Type Required Description
value String, tuple, list, or dictionary Yes The value.
• ### Response

The length of the specified value is returned.

• ### Examples

• Raw log
``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

The op_in function checks whether a string, tuple, list, or dictionary contains a specified element and returns True or False.
• ### Syntax

``op_in(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 String, tuple, list, or dictionary Yes The string, tuple, list, or dictionary.
value2 Arbitrary Yes The element that you want to check.
Note In a function, the specified string, tuple, list, or dictionary is placed before the specified element.
• ### Response

True is returned if the specified string, tuple, list, or dictionary contains the specified element. False is returned if the specified string, tuple, list, or dictionary does not contain the specified element.

• ### Examples

• Raw log
``````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

The op_not_in function checks whether a string, tuple, list, or dictionary does not contain a specified element and returns True or False.
• ### Syntax

``op_not_in(value1, value2)``
• ### Parameters

Parameter Type Required Description
value1 String, tuple, list, or dictionary Yes The string, tuple, list, or dictionary.
value2 Arbitrary Yes The element that you want to check.
Note In a function, the specified string, tuple, list, or dictionary is placed before the specified element.
• ### Response

True is returned if the specified string, tuple, list, or dictionary does not contain the specified element. False is returned if the specified string, tuple, list, or dictionary contains the specified element.

• ### Examples

• Raw log
``````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

The op_slice function extracts strings from a specified string, array, or tuple.
• ### Syntax

``op_slice(value, start, end=None, step=None)``
• ### Parameters

Parameter Type Required Description
value String Yes The value that you want to truncate to extract strings.
start Num No The position from which the value is truncated. Default value: 0.
end Num No The position to which the value is truncated. The character at this position is not included. The default value is the end of the specified string.
step Num No The step that is used for truncating.
• ### Response

The string that is extracted from the truncated value is returned.

• ### Examples

• Example 1: Truncate the value of the word field from the beginning to the end at a step of 2.
• Raw log
``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: Truncate the value of the word field from position 2 to position 9 at a step of 1.
• Raw log
``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

The op_index function returns the element that corresponds to the index of a specified string, array, or tuple.
• ### Syntax

``op_index(value, index)``
• ### Parameters

Parameter Type Required Description
value String Yes The string, array, or tuple.
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: Obtain the element that corresponds to the index 0 in the value of the word field.
• Raw log
``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: Obtain the element that corresponds to the index 3 in the value of the word field.
• Raw log
``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``````

The op_add function calculates the sum of multiple values. The values can be strings or numbers.
• ### Syntax

``op_add(value1, value2, ...)``
• ### Parameters

Parameter Type Required Description
value1 String, tuple, list, or dictionary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### 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.
• Raw log
``````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.
• Raw log
``````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 URL.
• Raw log
``host: aliyun.com``
• Transformation rule
``e_set("website", op_add("https://", v("host")))``
• Result
``````host: aliyun.com
website: https://aliyun.com``````

## op_max

The op_max function returns the largest value among the values of multiple fields or expressions.
• ### Syntax

``op_max(value1, value2, ...)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

The largest value among the specified values is returned.

• ### Examples

• Raw log
``````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

The op_min function returns the smallest value among the values of multiple fields or expressions.
• ### Syntax

``op_min(value1, value2, ...)``
• ### Parameters

Parameter Type Required Description
value1 Arbitrary Yes Value 1
value2 Must be the same as the data type of Value 1 Yes Value 2
• ### Response

The smallest value among the specified values is returned.

• ### Examples

• Raw log
``````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``````