All Products
Search
Document Center

Simple Log Service:Operator functions

Last Updated:Sep 14, 2026

This topic describes the syntax, parameters, and examples of operator functions.

Functions

Note

To use a negative value, use the op_neg(positive value) function. For example, to represent -1, use op_neg(1).

Type

Function

Description

Conditional functions

op_if

Returns the value of an expression based on a condition.

op_ifnull, op_coalesce

Returns the value of the first expression that is not None.

op_nullif

Returns None if Expression 1 equals Expression 2. Otherwise, returns the value of Expression 1.

op_and

Performs a logical AND operation. Returns True if all parameter values are true.

op_not

Performs a logical NOT operation. Returns the inverse Boolean value of the parameter.

op_or

Performs a logical OR operation. Returns True if any parameter value is true. Returns False if all parameter values are false.

Comparison

op_eq

Checks if a==b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

op_ge

Checks if a>=b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

op_gt

Checks if a>b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

op_le

Checks if a<=b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

op_lt

Checks if a<b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

op_ne

Checks if a!=b. Returns True or False.

The types of a and b must be the same, such as string, number, or list.

Determining the container

op_len

Calculates the number of characters in a text string. This function can be used for strings and other expressions that return a tuple, list, or dictionary.

op_in

Checks whether a string, tuple, list, or dictionary contains a specific element. Returns True or False.

op_not_in

Checks whether a string, tuple, list, or dictionary does not contain a specific element. Returns True or False.

op_slice

Slices a specified string, array, or tuple.

op_index

Returns an element from a string, array, or tuple based on its index.

General-purpose multivalued functions

op_add

Calculates the sum of multiple values, such as strings or numbers.

op_max

Returns the maximum value from multiple numeric fields or expressions.

op_min

Returns the minimum value from multiple numeric fields or expressions.

op_if

Returns the value of an expression based on a condition.

  • Syntax

    op_if(condition, expression1, expression2)
  • Parameters

    Parameter

    Parameter type

    Required

    Description

    condition

    Any

    Yes

    The condition to evaluate. If the condition is not a Boolean value, it is evaluated for truthiness. For more information, see Truthiness evaluation.

    expression1

    Any

    Yes

    The value to return if the condition is True.

    expression2

    Any

    Yes

    The value to return if the condition is False.

  • Response

    The value of the corresponding expression.

  • Examples

    • Example 1: If the content field evaluates to True, the value of expression1 is assigned to the test_if field.

      • Raw log

        content: hello
      • Transformation rule

        e_set("test_if", op_if(v("content"),"still origin content","replace this"))
      • Result

        content: hello
        test_if:  still origin content
    • Example 2: If the content field evaluates to False, the value of expression2 is assigned to the test_if field.

      • Raw log

        content: 0
      • Transformation rule

        e_set("test_if", op_if(ct_int(v("content", default=0)),"still origin content","replace this"))
      • Result

        content: 0
        test_if:  replace this

op_ifnull

Returns the value of the first expression that is not None.

  • Syntax

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

    Parameter Name

    Parameter Type

    Required

    Description

    expression1

    Any

    Yes

    Expression 1.

    expression2

    Any

    Yes

    Expression 2.

  • Response

    The value of the first expression that is not None.

  • 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

Returns the value of the first expression that is not None.

The parameters and examples for this function are similar to those for the op_ifnull function. For more information, see op_ifnull.

op_nullif

Returns None if Expression 1 equals Expression 2. Otherwise, returns the value of Expression 1.

  • Syntax

    op_nullif(expression1, expression2)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    expression1

    Any

    Yes

    Expression 1.

    expression2

    Any

    Yes

    Expression 2.

  • Response

    Returns None if Expression 1 and Expression 2 are equal. Otherwise, returns the value of Expression 1.

  • 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

        # Because the value of content is the same as the value of escape_name, no value is returned to the test_ifnull field.
        content: hello
        escape_name: hello

op_and

Performs a logical AND operation on values of any type. Returns True if all parameter values are true.

  • Syntax

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

    Parameter name

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    Any

    Yes

    Value 2.

  • Response

    • Returns True if all parameter values are true.

    • Values of any type are evaluated for truthiness. For more information, see Truthiness 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

Performs a logical NOT operation on a value of any type. Returns the inverse Boolean value of the expression.

  • Syntax

    op_not(expression)
  • Parameters

    Parameter

    Parameter Type

    Required

    Description

    expression

    Any

    Yes

    The expression.

  • Response

    • The inverse Boolean value of the expression.

    • Values of any type are evaluated for truthiness. For more information, see Truthiness 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

Performs a logical OR operation on values of any type. Returns True if any expression is true. Returns False if all expressions are false.

  • Syntax

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

    Parameter Name

    Parameter Type

    Required

    Description

    expression1

    Any

    Yes

    Expression 1.

    expression2

    Any

    Yes

    Expression 2.

  • Response

    • Returns True if any expression is true. Returns False if all expressions are false.

    • Values of any type are evaluated for truthiness. For more information, see Truthiness 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

Checks if a==b. Returns True or False.

  • Syntax

    op_eq(value1, value2)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    The value must be the same as value 1.

    Yes

    Value 2.

  • Response

    Returns True if value1 is equal to value2. Otherwise, returns False.

  • 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

Checks if a>=b. Returns True or False.

  • Syntax

    op_ge(value1, value2)
  • Parameters

    Parameter name

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    Must be the same type as value1

    Yes

    Value 2.

  • Response

    Returns True if value1 is greater than or equal to value2. Otherwise, returns False.

  • Examples

    • Example 1: Checks if the value of apple_price is greater than or equal to the value of orange_price.

      • 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: If the value of apple_price is less than the value of orange_price, the expression returns False.

      • 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

Checks if a>b. Returns True or False.

  • Syntax

    op_gt(value1, value2)
  • Parameters

    Parameter Name

    Parameter Type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    The value must match value 1.

    Yes

    Value 2.

  • Response

    Returns True if value1 is greater than value2. Otherwise, returns False.

  • Examples

    • Example 1: Checks if the value of old_number is greater than the value of young_number.

      • 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: Checks if the value of priority is greater than the value of price.

      • 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

Checks if a<=b. Returns True or False.

  • Syntax

    op_le(value1, value2)
  • Parameters

    Parameter Name

    Type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    The value must be 1.

    Yes

    Value 2.

  • Response

    Returns True if value1 is less than or equal to value2. Otherwise, returns False.

  • Examples

    • Example 1: Checks if the value of priority is less than or equal to the value of price.

      • 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 priority is less than or equal to the price, or False otherwise.

      • 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

Checks if a<b. Returns True or False.

  • Syntax

    op_lt(value1, value2)
  • Parameters

    Parameter

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    Must be the same type as value1

    Yes

    Value 2.

  • Response

    Returns True if value1 is less than value2. Otherwise, returns False.

  • Examples

    • Example 1: Returns True if the value of priority is less than that of price, and False otherwise.

      • 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: Checks if the value of priority is less than the value of price.

      • 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

Checks if a!=b. Returns True or False.

  • Syntax

    op_ne(value1, value2)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    The value must be the same as value 1.

    Yes

    Value 2.

  • Response

    Returns True if value1 is not equal to value2. Otherwise, returns False.

  • 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

Calculates the number of characters in a text string. This function can also be used with tuples, lists, and dictionaries.

  • Syntax

    op_len(value)
  • Parameters

    Parameter name

    Parameter type

    Required

    Description

    value

    String, tuple, list, or dictionary

    Yes

    The value to evaluate.

  • Response

    The length of the field.

  • 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

Checks whether a string, tuple, list, or dictionary contains a specific element. Returns True or False.

  • Syntax

    op_in(value1, value2)
  • Parameters

    Parameter name

    Parameter type

    Required

    Description

    value1

    String, tuple, list, or dictionary

    Yes

    The string, tuple, list, or dictionary.

    value2

    Any

    Yes

    The element to evaluate.

    Note

    The container (string, tuple, list, or dictionary) must be the first parameter, and the element must be the second.

  • Response

    Returns True if the container contains the element. Otherwise, returns False.

  • 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

Checks whether a string, tuple, list, or dictionary does not contain a specific element. Returns True or False.

  • Syntax

    op_not_in(value1, value2)
  • Parameters

    Parameter Name

    Parameter type

    Required

    Description

    value1

    String, tuple, list, or dictionary

    Yes

    The string, tuple, list, or dictionary.

    value2

    Any

    Yes

    The element to evaluate.

    Note

    The container (string, tuple, list, or dictionary) must be the first parameter, and the element must be the second.

  • Response

    Returns True if the container does not contain the element. Otherwise, returns False.

  • 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

Slices a specified string, array, or tuple.

  • Syntax

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

    Parameter name

    Parameter Type

    Required

    Description

    value

    String

    Yes

    The value to slice.

    start

    Number

    No

    The start position for the slice. Default value: 0.

    end

    Number

    No

    The end position for the slice. The character at this position is not included. The default value is the end of the string.

    step

    Number

    No

    Length of each capture.

  • Response

    The return value is the extracted string.

  • Examples

    • Example 1: Slice the 'word' field across its entire length with a step size 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: Slices the word field from position 2 to position 9 with a step size 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

Returns an element from a string, array, or tuple based on its index.

  • Syntax

    op_index(value, index)
  • Parameters

    Parameter name

    Parameter Type

    Required

    Description

    value

    String

    Yes

    The string, array, or tuple.

    index

    Number

    No

    The index in the input string, array, or tuple.

  • Response

    The element at the specified index.

  • Examples

    • Example 1: Returns the element at index 0 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: Returns the element at index 3 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

op_add

Adds multiple numbers or concatenates multiple strings.

  • Syntax

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

    Parameter name

    Parameter type

    Required

    Description

    value1

    String, tuple, list, or dictionary

    Yes

    Value 1.

    value2

    The value must match value 1.

    Yes

    Value 2.

  • Response

    Returns the summation result.

  • Examples

    • Example 1: Calculates the sum of price_orange and price_apple.

      • 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: Calculates the sum of bytes_in and bytes_out.

      • 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: Adds an 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

Returns the maximum value from multiple numeric fields or expressions.

  • Syntax

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

    Parameter name

    Parameter type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    The value must match value 1.

    Yes

    Value 2.

  • Response

    The maximum value among the parameters.

  • 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

Returns the minimum value from multiple numeric fields or expressions.

  • Syntax

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

    Parameter name

    Type

    Required

    Description

    value1

    Any

    Yes

    Value 1.

    value2

    Must be the same type as value1

    Yes

    Value 2.

  • Response

    The minimum value among the parameters.

  • 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