Skip to main content
Version: Next

BosFile

BOS file sink connector

Support Those Engines

Spark
Flink
SeaTunnel Zeta

Description

Output data to Baidu Cloud BOS (Baidu Object Storage) via the BOS HDFS SDK.

tip

If you use Spark/Flink, in order to use this connector you must ensure your Spark/Flink cluster already integrated Hadoop. The tested Hadoop version is 2.x.

If you use SeaTunnel Engine, Hadoop jars are bundled under ${SEATUNNEL_HOME}/lib.

To use this connector you need to put bos-hdfs-sdk (>= 1.0.4-community) into ${SEATUNNEL_HOME}/lib. Download: bos-hdfs-sdk-1.0.4-community.jar.zip.

Key Features

  • multimodal

    Use binary file format to read and write files in any format, such as videos, pictures, etc. In short, any files can be synchronized to the target place.

  • exactly-once

    By default, we use 2PC commit to ensure exactly-once

  • cdc

  • support multiple table write

  • timer flush

  • file format type

    • text
    • csv
    • parquet
    • orc
    • json
    • excel
    • xml
    • binary
    • canal_json
    • debezium_json
    • maxwell_json

Options

NameTypeRequiredDefaultDescription
pathstringyes-The target directory the sink writes to inside the bucket.
tmp_pathstringno/tmp/seatunnelThe result file will write to a tmp path first and then use mv to submit tmp dir to target dir. Needs a BOS dir.
bucketstringyes-The BOS bucket address, for example bos://my-bucket.
access_keystringyes-The Baidu Cloud BOS access key.
secret_keystringyes-The Baidu Cloud BOS secret key.
endpointstringyes-The BOS endpoint, for example http://bj.bcebos.com.
custom_filenamebooleannofalseWhether you need custom the filename.
file_name_expressionstringno"${transactionId}"Only used when custom_filename is true.
filename_time_formatstringno"yyyy.MM.dd"Only used when custom_filename is true.
file_format_typestringno"csv"File format type, supported: text, csv, parquet, orc, json, excel, xml, binary, canal_json, debezium_json, maxwell_json.
filename_extensionstringno-Override the default file name extensions with custom file name extensions. E.g. .xml, .json, dat, .customtype
field_delimiterstringno'\001' for text and ',' for csvOnly used when file_format_type is text and csv.
row_delimiterstringno"\n"Only used when file_format_type is text, csv and json.
have_partitionbooleannofalseWhether you need processing partitions.
partition_byarrayno-Only used when have_partition is true.
partition_dir_expressionstringno"${k0}=${v0}/${k1}=${v1}/.../${kn}=${vn}/"Only used when have_partition is true.
is_partition_field_write_in_filebooleannofalseOnly used when have_partition is true.
sink_columnsarraynoWhen this parameter is empty, all fields are sink columns.
is_enable_transactionbooleannotrueIf true, data will not be lost or duplicated when written to the target directory. When true, ${transactionId}_ is automatically prefixed to the file name.
batch_sizeintno1000000The maximum number of rows in a file. For SeaTunnel Engine the file row count is jointly decided by batch_size and checkpoint.interval.
compress_codecstringnononeThe compress codec of files. Excel does not support any compression format.
xml_root_tagstringnoRECORDSOnly used when file_format is xml.
xml_row_tagstringnoRECORDOnly used when file_format is xml.
xml_use_attr_formatbooleanno-Only used when file_format is xml.
single_file_modebooleannofalseEach parallelism will only output one file. When this parameter is turned on, batch_size will not take effect. The output file name does not have a file block suffix.
create_empty_file_when_no_databooleannofalseWhen there is no data synchronization upstream, the corresponding data files are still generated.
parquet_avro_write_timestamp_as_int96booleannofalseOnly used when file_format is parquet.
parquet_avro_write_fixed_as_int96arrayno-Only used when file_format is parquet.
encodingstringno"UTF-8"Only used when file_format_type is json,text,csv,xml.
common-optionsobjectno-Sink plugin common parameters, please refer to Sink Common Options for details.

Example

For text file format with have_partition, custom_filename and sink_columns:

env {
parallelism = 1
job.mode = "BATCH"
}

sink {
BosFile {
path = "/sink"
bucket = "bos://sink-bucket"
access_key = "your-access-key"
secret_key = "your-secret-key"
endpoint = "http://bj.bcebos.com"
file_format_type = "text"
field_delimiter = "\t"
row_delimiter = "\n"
have_partition = true
partition_by = ["age"]
partition_dir_expression = "${k0}=${v0}"
is_partition_field_write_in_file = true
custom_filename = true
file_name_expression = "${transactionId}_${now}"
filename_time_format = "yyyy.MM.dd"
sink_columns = ["name", "age"]
is_enable_transaction = true
}
}

For parquet file format:

sink {
BosFile {
path = "/sink"
bucket = "bos://sink-bucket"
access_key = "your-access-key"
secret_key = "your-secret-key"
endpoint = "http://bj.bcebos.com"
file_format_type = "parquet"
is_enable_transaction = true
}
}

Simple text sink:

sink {
BosFile {
bucket = "bos://sink-bucket"
path = "/warehouse/table/"
file_format_type = "text"
access_key = "your-access-key"
secret_key = "your-secret-key"
endpoint = "http://bj.bcebos.com"
row_delimiter = "\n"
field_delimiter = ","
is_enable_transaction = true
}
}

Changelog

Change Log
ChangeCommitVersion
[Improve][Connector-V2] Add Hive BOSStorage and align BosFile e2e/docs with CosFilehttps://github.com/apache/seatunnel/pull/11952dev
[Feature][Connector-V2] Add BosFile source and sink for Baidu Object Storagehttps://github.com/apache/seatunnel/pull/11952dev