TOS data source
The TOS data source provides the capability to read TOS files. You can use this data source to retrieve files stored in TOS, parse them, and synchronize the data to any destination data source. This topic describes the data synchronization capabilities supported by DataWorks for TOS.
Limitations
The TOS data source supports the following column types in DataWorks.
|
Data type |
Description |
|
STRING |
Text type. |
|
LONG |
Integer type. |
|
BYTES |
Byte array. Converts the read text content into a |
|
BOOL |
Boolean type. |
|
DOUBLE |
Floating-point type. |
|
DATE |
Date and time type. The following date and time formats are supported:
|
Create a TOS data source
Before you develop a synchronization task in DataWorks, you must add the required data source to DataWorks by following the instructions in Data source configuration. You can view parameter descriptions in the DataWorks console to understand the meanings of the parameters when you add a data source.
Develop a data synchronization task
The TOS data source can only be used as the source in single-table batch synchronization tasks. The following describes the entry point and the general configuration process for data synchronization tasks.
-
For the procedure, see Codeless UI configuration and Script mode configuration.
-
For the full set of parameters and a script demo for script mode, see Appendix: Script demo and parameters below.
Appendix: Script demo and parameters
Configure a batch synchronization task by using the code editor
If you want to configure a batch synchronization task by using the code editor, you must configure the related parameters in the script based on the unified script format requirements. For more information, see Script mode configuration. The following information describes the parameters that you must configure for data sources when you configure a batch synchronization task by using the code editor.
Reader script demo
{
"type": "job",
"version": "2.0",
"steps": [
{
"stepType": "tos",
"parameter": {
"datasource": "",
"object": ["f/z/1.csv"],
"fileFormat": "csv",
"encoding": "utf8/gbk/...",
"fieldDelimiter": ",",
"useMultiCharDelimiter": true,
"skipHeader": true,
"compress": "zip/gzip",
"column": [
{
"index": 0,
"type": "long"
},
{
"index": 1,
"type": "boolean"
},
{
"index": 2,
"type": "double"
},
{
"index": 3,
"type": "string"
},
{
"index": 4,
"type": "date"
}
]
},
"name": "Reader",
"category": "reader"
},
{
"stepType": "stream",
"parameter": {},
"name": "Writer",
"category": "writer"
}
],
"setting": {
"errorLimit": {
"record": "0"
},
"speed": {
"concurrent": 1
}
},
"order": {
"hops": [
{
"from": "Reader",
"to": "Writer"
}
]
}
}
Reader script parameters
|
Parameter |
Description |
Required |
Default value |
|
datasource |
The data source name. Script mode supports adding data sources. The value of this parameter must match the name of the added data source. |
Yes |
None |
|
fileFormat |
The source file type. Supported types: |
Yes |
None |
|
object |
The file path. This parameter is used when fileFormat is set to csv, text, json, or jsonl. This parameter supports the * wildcard and can be configured as an array. For example, to synchronize the two files a/b/1.csv and a/b/2.csv, you can configure a/b/*.csv. |
Yes Required when fileFormat is set to csv, text, json, or jsonl. |
None |
|
column |
The list of columns to read. type specifies the source data type:
Note
For the column information you specify, type is required. For the CSV/TEXT format, choose one of index or value. For the JSON/JSONL format, choose one of jsonPath or value. |
Yes |
All read as |
|
fieldDelimiter |
The field delimiter for reading. Note
|
Yes |
|
|
lineDelimiter |
The row delimiter for reading. Note
This parameter takes effect only when fileFormat is set to text. |
No |
None |
|
compress |
The text compression type. Empty by default (no compression). Supported compression types: |
No |
|
|
encoding |
The encoding used to read the file. |
No |
|
|
nullFormat |
Text files cannot define null (null pointer) using a standard string. The data synchronization system provides nullFormat to define which strings can be treated as null. For example:
|
No |
None |
|
skipHeader |
For CSV files, use skipHeader to control whether the header is read.
Note
skipHeader is not supported in compressed file mode. |
No |
|
|
parquetSchema |
Configure this parameter when reading TOS in Parquet file format. It takes effect only when fileFormat is parquet, and describes the storage type of the Parquet data. Make sure that the entire configuration conforms to JSON syntax after parquetSchema is filled in.
|
No |
None |
|
csvReaderConfig |
The configuration parameters for reading CSV files, as a Map type. Reading CSV files uses csvReader. If not configured, default values are used. |
No |
None |