I/O APIs
write_iceberg
Description: Writes data to a specified Iceberg table.
Syntax:
write_iceberg(target_name, database, create_if_not_exists=False, overwrite=False, is_external=False, schema=None, explain = None, verbose = True)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| target_name | Yes | str | Name of the target table that data is written to. |
| database | Yes | str | Database that the table belongs to. |
| create_if_not_exists | No | bool | If this parameter is set to True, the table will be automatically created if it does not exist. |
| overwrite | No | bool | If this parameter is set to True, the existing data in the table will be overwritten. |
| is_external | No | bool | If this parameter is set to True, the table is treated as an external table. |
| schema | No | Any type | (Optional) Schema definition of the table. |
| explain | No | String | The value can be set to plan or performance. plan prints only the execution plan, while performance prints the execution details. |
| verbose | No | bool | If this parameter is set to True and explain set to plan, additional detailed information will be printed. |
Return type: str
write_orc
Description: Writes data to a specified ORC table.
Syntax:
write_orc(target_name, database, create_if_not_exists=False, overwrite=False, is_external=False, schema=None, explain = None, verbose = True)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| target_name | Yes | str | Name of the target table that data is written to. |
| database | Yes | str | Database that the table belongs to. |
| create_if_not_exists | No | bool | If this parameter is set to True, the table will be automatically created if it does not exist. |
| overwrite | No | bool | If this parameter is set to True, the existing data in the table will be overwritten. |
| is_external | No | bool | If this parameter is set to True, the table is treated as an external table. |
| schema | No | Any type | (Optional) Schema definition of the table. |
| explain | No | String | The value can be set to plan or performance. plan prints only the execution plan, while performance prints the execution details. |
| verbose | No | bool | If this parameter is set to True and explain set to plan, additional detailed information will be printed. |
Return type: str
write_parquet
Description: Writes data to a specified Parquet table.
Syntax:
write_parquet(target_name, database, create_if_not_exists=False, overwrite=False, is_external=False, schema=None, explain = None, verbose = True)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| target_name | Yes | str | Name of the target table that data is written to. |
| database | Yes | str | Database that the table belongs to. |
| create_if_not_exists | No | bool | If this parameter is set to True, the table will be automatically created if it does not exist. |
| overwrite | No | bool | If this parameter is set to True, the existing data in the table will be overwritten. |
| is_external | No | bool | If this parameter is set to True, the table is treated as an external table. |
| schema | No | Any type | (Optional) Schema definition of the table. |
| explain | No | String | The value can be set to plan or performance. plan prints only the execution plan, while performance prints the execution details. |
| verbose | No | bool | If this parameter is set to True and explain set to plan, additional detailed information will be printed. |
Return type: str
write_text
Description: Writes text data to a specified OBS path.
Syntax:
write_text(path, field_delim, max_rows_per_file=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| path | Yes | str | OBS path for storing text files. |
| field_delim | Yes | str | Field delimiter for rows in the TEXT data file. The value cannot be any character in \\.abcdefghijklmnopqrstuvwxyz0123456789. |
| max_rows_per_file | No | int | Maximum number of rows that can be written to a file |
Return type: None.
write_json
Description: Writes JSON data to a specified OBS path.
Syntax:
write_json(path, max_rows_per_file=None, ignore_null_fields=False, nested_separator=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| path | Yes | str | OBS path for storing JSON data. |
| max_rows_per_file | No | int | Maximum number of rows that can be written to a file |
| ignore_null_fields | No | bool | Whether to ignore the JSON keys with NULL values when writing JSON objects. |
| nested_separator | No | str | Separator for concatenating nested JSON keys. The value cannot be a number sign (#). For example, if this parameter is set to an underscore (_), {"a":{"b":1}} will be mapped to column a_b with value 1. By default, nested JSON read and write are not supported. |
Return type: None.
read_text
Description: Reads TEXT files from a specified OBS path and writes them to a dataset with a specified schema.
Syntax:
read_text(path, schema, field_delim='\t', drop_empty_lines=True, fill_missing_fields=False, ignore_extra_data=False)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| path | Yes | str | Directory for storing text files in OBS. |
| schema | Yes | dict | Column information for reading the text file. |
| field_delim | No | str | Field delimiter for rows in the TEXT data file. The value cannot be any character in \\.abcdefghijklmnopqrstuvwxyz0123456789. |
| drop_empty_lines | No | bool | Whether to discard empty lines or single-line \n, \r, and \t in the text. |
| fill_missing_fields | No | bool | Whether to report an error when the number of columns after splitting by field_delim is less than the number of columns. |
| ignore_extra_data | No | bool | Whether to report an error when the number of columns after splitting by field_delim exceeds the number of columns. |
Return type: Dataset, which is a collection of text data.
read_json
Description: Reads the JSON value of a specified JSON key from a specified OBS path based on the schema.
Syntax:
read_json(path, schema, skip_empty_files=False, nested_separator=None)
Input parameters:
| Parameter | Mandatory (Yes/No) | Data Type | Description |
|---|---|---|---|
| path | Yes | str | Directory for storing JSON files in OBS. |
| schema | Yes | dict | Column information for reading the specified key. |
| skip_empty_files | No | bool | Whether to skip the JSON content that is {}. |
| nested_separator | No | str | Separator for concatenating nested JSON keys. The value cannot be a number sign (#). For example, if this parameter is set to an underscore (_), {"a":{"b":1}} will be mapped to column a_b with value 1. By default, nested JSON read and write are not supported. |
Return type: Dataset, which is a collection of JSON objects.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot