OBS data source
An OBS data source allows you to read files. You can use this data source to retrieve files stored in OBS, parse the files, and synchronize the data to any destination data source. This topic describes the capabilities supported for OBS data synchronization in DataWorks.
Limits
An OBS data source supports the following data types.
|
Data type |
Description |
|
STRING |
Text. |
|
LONG |
Integers. |
|
BYTES |
Byte arrays. The text read is converted to UTF-8-encoded byte arrays. |
|
BOOL |
Boolean values. |
|
DOUBLE |
Floating-point numbers. |
|
DATE |
Date and time values. The following date and time formats are supported:
|
Create a data source
When you develop a data synchronization task, you must create a corresponding data source in DataWorks. For more information about the procedure, see Create and manage data sources. For detailed explanations of the configuration parameters, view the hints for the corresponding parameters in the configuration UI.
Develop a data synchronization task
For information about where to configure data synchronization tasks and the general configuration procedure, see the following configuration guides.
Configuration guides for single-table batch synchronization tasks
-
For more information about the procedure, see Configure a batch synchronization task by using the codeless UI and Configure a batch synchronization task in script mode.
-
For all parameters and a sample script for configuration in script mode, see Appendix: Sample script and parameter descriptions below.
Appendix: Sample script and parameter descriptions
Configure a batch task in script mode
If you configure a batch task in script mode, you must specify the corresponding parameters in the task script in accordance with the standard script format requirements. For more information, see Configure a batch synchronization task in script mode. The following sections describe the data source parameter configurations in script mode.
Sample Reader script
{
"type": "job",
"version": "2.0",
"steps": [
{
"stepType": "obs",
"parameter": {
"datasource": "",
"object": ["f/z/1.csv"],
"fileFormat": "csv",
"encoding": "utf8/gbk/...",
"fieldDelimiter": ",",
"useMultiCharDelimiter": true,
"lineDelimiter": "\n",
"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 name of the data source. Script mode supports adding data sources. The value of this parameter must match the name of the added data source. |
Yes |
None |
|
fileFormat |
The type of the source file. Supported types: csv, text, parquet, and orc. |
Yes |
None |
|
object |
The file path. This parameter is used when fileFormat is set to csv or text. |
Yes (required when fileFormat is set to csv or text) |
None |
|
column |
The list of fields to read. type specifies the data type of the source data. index specifies the column in the text from which the current column is read, starting from 0. value specifies that the current type is a constant. Instead of reading data from the source file, the corresponding column is automatically generated based on the value of value. |
Yes |
All data is read as the STRING type. |
|
fieldDelimiter |
The field delimiter used to read data.
|
Yes |
, |
|
lineDelimiter |
The line delimiter used to read data. |
No |
None |
|
compress |
The text compression type. This parameter is left unspecified by default, which means no compression. Supported compression types: gzip, bzip2, and zip. |
No |
No compression |
|
encoding |
The encoding used to read files. |
No |
utf-8 |
|
nullFormat |
A standard string cannot define null (a null pointer) in a text file. The data synchronization system provides nullFormat to specify which strings represent null. For example:
|
No |
None |
|
skipHeader |
For CSV files, skipHeader specifies whether to read the header content.
Note |
No |
false |
|
parquetSchema |
Configure this parameter when reading OBS data in Parquet file format. This parameter takes effect if and only if fileFormat is set to parquet and describes the types stored in parquet. After you specify parquetSchema, make sure that the entire configuration complies with JSON syntax.
The following example shows a configuration: |
No |
None |
|
csvReaderConfig |
Parameters for reading CSV files are configured as a Map. CSV files are read by using CsvReader. If you do not configure this parameter, the default values are used. |
No |
None |