Operations with active lists and dictionaries
active_list and active_list_dyn
These functions allow you to receive information from an active list and dynamically generate a field name for an active list and key.
You must specify the parameters in the following sequence:
Usage example |
Result |
|
Gets the field value of the active list. |
You can use these functions to reference an active list of the Shared tenant from a variable. To do so, add the @Shared suffix after the name of the active list (case sensitive). For example, active_list('exampleActiveList@Shared', 'score', SourceAddress, SourceUserName).
table_dict
Gets information about the value in the specified column of a dictionary of the table type.
You must specify the parameters in the following sequence:
Usage example |
Result |
|
Gets data from the |
|
Gets data from the |
You can use this function to reference a dictionary of the Shared tenant from a variable. To do so, add the @Shared
suffix after the name of the active list (case sensitive). For example, table_dict('exampleTableDict@Shared', 'office', SourceUserName)
.
dict
Gets information about the value in the specified column of a dictionary of the dictionary type.
You must specify the parameters in the following sequence:
Usage example |
Result |
|
Gets data from |
|
Gets data from the |
You can use this function to reference a dictionary of the Shared tenant from a variable. To do so, add the @Shared
suffix after the name of the active list (case sensitive). For example, dict('exampleDictionary@Shared', SourceAddress)
.
Operations with context tables
context_table
Returns the value of the specified field in the base type (for example, integer, array of integers).
You must specify the parameters in the following sequence:
The function must contain at least 4 parameters.
Usage example |
Result |
|
|
len
Returns the length of a string or array.
The function returns the length of the array if the passed array is of one of the following types:
If an array of a different type is passed, the data of the array is cast to the string type, and the function returns the length of the resulting string.
Usage examples |
|
|
distinct_items
Returns a list of unique elements in an array.
The function returns the list of unique elements of the array if the passed array is of one of the following types:
If an array of a different type is passed, the data of the array is cast to the string type, and the function returns a string consisting of the unique characters from the original string.
Usage examples |
|
|
sort_items
Returns a sorted list of array elements.
You must specify the parameters in the following sequence:
asc
, desc
. If the parameter is not specified, the default value is asc
.The function returns the list of sorted elements of the array if the passed array is of one of the following types:
For a boolean array, the function returns the list of array elements in the original order.
If an array of a different type is passed, the data of the array is cast to the string type, and the function returns a string of sorted characters.
Usage examples |
|
|
item
Returns the array element with the specified index or the character of a string with the specified index if an array of integers, floats, strings, or boolean values is passed.
You must specify the parameters in the following sequence:
The function must contain at least 2 parameters.
The function returns the array element with the specified index or the string character with the specified index if the index falls within the range of the array and the passed array is of one of the following types:
If an array of a different type is passed and the index falls within the range of the array, the data is cast to the string type, and the function returns the string character with the specified index. If an array of a different type is passed and the index is outside the range of the array, the function returns an empty string.
Usage examples |
|
|
Operations with strings
to_lower
Converts characters in a string to lowercase. Supported for standard fields and extended event schema fields of the string
type.
A string can be passed as a string, field name or variable.
Usage examples |
|
|
|
to_upper
Converts characters in a string to uppercase. Supported for standard fields and extended event schema fields of the string
type. A string can be passed as a string, field name or variable.
Usage examples |
|
|
|
append
Adds characters to the end of a string. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable.
Usage examples |
Usage result |
|
The string |
|
The string |
|
A string from |
prepend
Adds characters to the beginning of a string. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable.
Usage examples |
Usage result |
|
The string |
|
The string |
|
A string from |
substring
Returns a substring from a string. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable. If the position number is greater than the original data string length, an empty string is returned.
Usage examples |
Usage result |
|
Returns a part of the string from the |
|
Returns a part of the string from the |
|
Returns the entire string from the |
index_of
The index_of
function returns the byte offset of a character or substring in a string; the first character in the string has index 0. If the function does not find the substring, the function returns a negative value.
If the string has non-ASCII characters, the returned byte offset will not correspond to the number of characters preceding the substring you are searching for.
The function accepts the following parameters:
To use this function, you must specify the parameters in the following order:
Usage examples |
Usage result |
|
The function looks for the Result = 4 The function returns the index of the first occurrence of the character in the string. The first character in the string has index 0. |
|
The function looks for the Result = 8 The function returns the index of the first occurrence of the character in the string. The first character in the string has index 0. |
last_index_of
The last_index_of
function returns the position of the last occurrence of a character or substring in a string; the first character in the string has index 0. If the function does not find the substring, the function returns -922337203685477580.
The function accepts the following parameters:
To use this function, you must specify the parameters in the following order:
Usage examples |
Usage result |
|
The function looks for the Result = 15 The function returns the index of the last occurrence of the character in the string. The first character in the string has index 0. |
tr
Deletes the specified characters from the beginning and end of a string. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable. If you do not specify a string to be deleted, spaces will be removed from the beginning and end of the original string.
Usage examples |
Usage result |
|
Spaces have been removed from the beginning and end of the string from the |
|
If the |
|
If the |
replace
Replaces all occurrences of character sequence A in a string with character sequence B. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as an expression.
Usage examples |
Usage result |
|
Returns a string from the |
|
Returns a string from |
regexp_replace
Replaces a sequence of characters that match a regular expression with a sequence of characters and regular expression capturing groups. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable. Unnamed capturing groups can be used.
In regular expressions used in variable functions, each backslash character must be additionally escaped. For example, ^example\\\\
must be used instead of the regular expression ^example\\
.
Usage examples |
Usage result |
|
Returns a string from the |
regexp_capture
Gets the result matching the regular expression condition from the original string. Supported for standard fields and extended event schema fields of the string
type.
You must specify the parameters in the following sequence:
Strings can be passed as a string, field name or variable. Unnamed capturing groups can be used.
In regular expressions used in variable functions, each backslash character must be additionally escaped. For example, ^example\\\\
must be used instead of the regular expression ^example\\
.
Usage examples |
Example values |
Usage result |
|
|
|
template
Returns the string specified in the function, with variables replaced with their values. The template function can be used in one of two ways:
Usage examples |
|
Operations with timestamps
now function
Gets a timestamp in epoch format. Runs with no arguments.
Usage examples |
|
extract_from_timestamp
Gets atomic time representations (year, month, day, hour, minute, second, day of the week) from fields and variables with time in the epoch format.
The parameters must be specified in the following sequence:
Possible variants of atomic time notation:
Usage examples |
|
|
|
|
parse_timestamp
Converts the time from RFC3339 format (for example, 2022-05-24 00:00:00
, 2022-05-24 00:00:00+0300
) to epoch format.
Usage examples |
|
|
format_timestamp
Converts the time from epoch format to RFC3339 format.
The parameters must be specified in the following sequence:
Usage examples |
|
|
|
truncate_timestamp
Rounds the time in epoch format. After rounding, the time is returned in epoch format. Time is rounded down.
The parameters must be specified in the following sequence:
Usage examples |
Examples of rounded values |
Usage result |
|
1654631774175 (7 June 2022, 19:56:14.175) |
1654631760000 (7 June 2022, 19:56:00) |
|
1654631774175 (7 June 2022, 19:56:14.175) |
1654628400000 (7 June 2022, 19:00:00) |
|
1654631774175 (7 June 2022, 19:56:14.175) |
1654560000000 (7 June 2022, 0:00:00) |
time_diff
Gets the time interval between two timestamps in epoch format.
The parameters must be specified in the following sequence:
Usage examples |
|
|
|
Mathematical operations
These are comprised of basic mathematical operations and functions.
Basic mathematical operations
Supported for extended event schema fields of the integer
and float
types.
Operations:
Parentheses determine the sequence of actions
Available arguments:
When modulo dividing, only natural numbers can be used as arguments.
Usage constraints:
Usage examples
|
Usage result |
|
4 |
|
-1 |
|
5 |
|
0 |
|
0 |
|
10 |
|
1 |
round
Rounds numbers. Supported for extended event schema fields of the integer
and float
types.
Available arguments:
Usage examples
|
Usage result |
|
8 |
|
8 |
|
7 |
ceil
Rounds up numbers. Supported for extended event schema fields of the integer
and float
types.
Available arguments:
Usage examples
|
Usage result |
|
8 |
|
9 |
floor
Rounds down numbers. Supported for extended event schema fields of the integer
and float
types.
Available arguments:
Usage examples
|
Usage result |
|
7 |
|
8 |
abs
Gets the modulus of a number. Supported for extended event schema fields of the integer
and float
types.
Available arguments:
Usage examples
|
Usage result |
|
7 |
|
2 |
pow
Exponentiates a number. Supported for extended event schema fields of the integer
and float
types.
The parameters must be specified in the following sequence:
Available arguments:
Usage examples |
|
|
str_join
Join multiple strings into one using a separator. Supported for extended event schema fields of the integer
and float
types.
The parameters must be specified in the following sequence:
Usage examples |
Usage result |
|
String. |
conditional
Get one value if a condition is met and another value if the condition is not met. Supported for extended event schema fields of the integer
and float
types.
The parameters must be specified in the following sequence:
Supported operators:
AND
OR
NOT
=
!=
<
<=
>
>=
LIKE
(passes a RE2 regular expression, not an SQL expression)ILIKE
(passes a RE2 regular expression, not an SQL expression)BETWEEN
IN
IS NULL
(check for an empty value, such as 0 or an empty string)Usage examples (the value depends on arguments 2 and 3) |
|
|
|
Operations for extended event schema fields
For extended event schema fields of the string
type, the following operations are supported:
len
to_lower
to_upper
append
prepend
substring
tr
replace
regexp_replace
regexp_capture
For extended event schema fields of the integer
or float
type, the following operations are supported:
round
ceil
floor
abs
pow
str_join
conditional
For extended event schema fields of the array of integers
, array of floats
, and array of strings
types, KUMA supports the following functions:
item(<type>.someStringArray)
.<type>.someStringArray
. Returns ["string1", "string2", "string3"]
.len(<type>.someStringArray)
. Returns ["string1", "string2"]
.distinct_items(<type>.someStringArray)
.to_string(<type>.someStringArray)
.sort_items(<type>.someStringArray)
.In the examples, instead of <type>
, you must specify the array type: NA for an array of integers, FA for an array of floats, SA for an array of strings.
For fields of the array of integers
and array of floats
types, the following functions are supported:
math_min
returns the minimum element of an array. Example: math_min(NA.NumberArray)
, math_min(FA.FloatArray)
.math_max
returns the maximum element of an array Example: math_max(NA.NumberArray)
, math_max(FA.FloatArray)
.math_avg
returns the average value of an array. Example: math_avg(NA.NumberArray)
, math_avg(FA.FloatArray)
.