This topic describes the data structures that are related to the data transformation syntax.
Basic data structures
The following table describes the different types of basic data structures.
Type | Description |
Integer | You can use integers as field values. You can also pass integers as values of parameters to functions. For example, |
Float | You can use float values as field values. You can also pass float values as values of parameters to functions. For example, |
String | Strings can be specified in multiple formats. Examples:
Note A field value must be enclosed in double quotation marks (""). You can use single quotation marks('') to enclose the string and double quotation marks ("") to enclose the field value. For example, |
Byte | Example: |
None | Both Note None or null is different from an empty string. |
List | An array. Example: [1,2,3,4].
|
Tuple | Tuples and lists function in the same manner. Example: |
Dictionary | A dictionary is a collection of key-value pairs in the
|
Boolean | Examples: |
Table | Each table consists of multiple columns. You can construct a table by loading multi-row CSV-formatted data from an external resource. You can also construct a table by loading multiple columns of data from ApsaraDB RDS instances and Logstores. Tables are suitable for advanced operations such as data mapping and enrichment. |
Datetime object | A datetime object is a memory object that indicates date and time information. A datetime object can be converted to a UNIX timestamp or a formatted time string. A datetime object can be passed to |
Event types
The following list describes event types:
Basic types
Log data is processed into the dictionary structure during the data transformation process. Example:
{"__topic__": "access_log", "content": "....."}
.The keys and values of a dictionary correspond to the fields and values in a log.
NoteThe keys and values of an event are strings, and the keys must be unique.
Meta-fields
The following meta-fields are supported:
__time__
: the log time that is specified when log data is written. The value is a string that represents an integer and follows the UNIX time format. It is the number of seconds that have elapsed since 00:00:00 Thursday, January 1, 1970.__topic__
: the topic of a log. Topics are used to group logs in a Logstore. You can specify a topic for logs when the logs are written to a Logstore. You can specify a topic when you query logs.__source__
: the source of a log. For example, the value of this field can be the IP address of the server on which the log is generated.
Modification of the __time__ field
You can change the value of the __time__ field to modify the event time of a log. You can use date and time functions to perform more operations on the __time__ field.
NoteIf the __time__ field is deleted, the system time at which a log is processed is used as the event time at which the log is written to a destination Logstore.
Tags
Tags are used to differentiate fields in logs. Tags are in the
__tag__:Name
format.If the source Logstore is configured to record public IP addresses, logs contain
tag: __tag__:__receive_time__
.Container logs contain many container-related tags. Example:
__tag__:__container_name__
.You can add and modify tags. For example, you can add a tag named type:
e_set("__tag__:type", "access_log")
.
Automatic conversion during value assignment
The keys and values of an event are strings. When you assign a value to a key or when you specify a new value for a key in an event, the key and the value of the key are automatically converted to strings. Examples:
e_set("v1", 12.3) e_set("v2", True)
Set
v1
to the 12.3 string and setv2
to the true string.The following table provides examples on the conversion of different data types to strings.
Original type
Example
New type
Example
Integer
1
String
"1"
Float
1.2
String
"1.2"
Boolean
True
String
"true"
Byte
b"123"
String that is encoded in UTF-8
"123"
Tuple
Example 1:
(1, 2, 3)
Example 2:
("a", 1)
String that represents a list
Example 1:
"[1, 2, 3]"
Example 2:
"[\"a\", 1]"
List
Example 1:
[1,2,3]
Example 2:
["a", 1]
String
Example 1:
"[1, 2, 3]"
Example 2:
"[\"a\", 1]"
Dictionary
{"1":2, "3":4}
String
"{\"1\": 2, \"3\": 4}"
Datetime
datetime(2018, 10, 10, 10, 10, 10)
String that represents time in the ISO format
2018-10-10 10:10:10
Fixed identifiers
The data transformation feature provides fixed identifiers. You can use the identifiers to simplify code.
Identifier | Type | Description |
true | Boolean | Equivalent to |
false | Boolean | Equivalent to |
null | None | Equivalent to |
F_TAGS | String | The regular expression that represents the |
F_META | String | The regular expression that represents the combination of the |
F_TIME | String | The name of the |
F_PACK_META | String | The regular expression that represents the |
F_RECEIVE_TIME | String | The |
C_JOB_REGION | String | The region ID of a data transformation job. Example: |
C_JOB_PROJECT | String | The name of the project to which a data transformation job belongs. Example: |
C_JOB_NAME | String | The configuration name of a data transformation job. Example: |
C_JOB_ID | String | The running ID of a data transformation job. Example: |
JSON objects
A JSON object is an object that you obtain after the JSON expression function json_select
or json_parse
is used to parse data. A JSON object consists of data in basic data structures. The following table provides examples on the conversion of strings to JSON objects.
String | JSON object | Type |
|
| Integer |
|
| Float |
|
| Boolean |
|
| Boolean |
|
| String |
|
| None |
|
| List |
|
| List |
|
| Dictionary |
|
| Dictionary |