Skip to main content
Version: Next

SmbFile

SMB file source connector

Support Those Engines​

Spark
Flink
SeaTunnel Zeta

Key Features​

Description​

Read data from SMB (Server Message Block) file shares. SMB is a network file sharing protocol that allows applications to read and write files on remote servers.

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, It automatically integrated the hadoop jar when you download and install SeaTunnel Engine. You can check the jar package under ${SEATUNNEL_HOME}/lib to confirm this.

Supported DataSource Info​

DatasourceSupported VersionsDependency
SmbFileSMB2/SMB3Download

Data Type Mapping​

The File does not have a specific type list, and we can indicate which SeaTunnel data type the corresponding data needs to be converted to by specifying the Schema in the config.

SeaTunnel Data type
STRING
SHORT
INT
BIGINT
BOOLEAN
DOUBLE
DECIMAL
FLOAT
DATE
TIME
TIMESTAMP
BYTES
ARRAY
MAP

Source Options​

NameTypeRequireddefault valueDescription
hostStringYes-The SMB server host
portIntNo445The SMB server port
userStringYes-The SMB authentication username
passwordStringNo-The SMB authentication password
domainStringNo(empty)The SMB authentication domain (e.g. WORKGROUP)
shareStringYes-The SMB share name to connect to
pathStringYes-The source file path within the share
file_format_typeStringYes-Supported file types: text csv parquet orc json excel xml binary markdown pdf
file_filter_patternStringNo-Filter pattern, which used for filtering files.
delimiter/field_delimiterStringNo\001 for text and ',' for csvField delimiter, used to tell connector how to slice and dice fields when reading text files.
row_delimiterStringNo\nRow delimiter, used to tell connector how to slice and dice rows when reading text files.
parse_partition_from_pathBooleanNotrueControl whether parse the partition keys and values from file path
date_formatStringNoyyyy-MM-ddDate type format
datetime_formatStringNoyyyy-MM-dd HH:mm:ssDatetime type format
time_formatStringNoHH:mm:ssTime type format
skip_header_row_numberLongNo0Skip the first few lines, but only for the txt and csv.
schemaConfigNo-The schema of upstream data
read_columnsListNo-The read column list of the data source, user can use it to implement field projection.
sheet_nameStringNo-Reader the sheet of the workbook, Only used when file_format is excel.
xml_row_tagStringNo-Specifies the tag name of the data rows within the XML file, only used when file_format is xml.
xml_use_attr_formatBooleanNo-Specifies whether to process data using the tag attribute format, only used when file_format is xml.
compress_codecStringNoNoneThe compress codec of files
encodingStringNoUTF-8The encoding of the file to read
null_formatStringNo-Only used when file_format_type is text. Define which strings can be represented as null, e.g. \N.
filename_extensionStringNo-Filter filename extension, which used for filtering files with specific extension. Example: csv .txt json .xml.
excel_engineStringNoPOIOnly used when file_format is excel. Supported engines are POI and EasyExcel.
poi_excel_max_file_sizeLongNo52428800Only used when file_format is excel and excel_engine is POI. The maximum Excel file size in bytes (default 50 MB).
quote_charStringNo"A single character that encloses CSV fields, allowing fields with commas, line breaks, or quotes to be read correctly.
escape_charStringNo-A single character that allows the quote or other special characters to appear inside a CSV field without ending the field.
metalake_typeStringNogravitinoThe type of metalake service, currently supports gravitino.
discovery_modeStringNoonceFile discovery mode. Supported values: once (default), continuous. When continuous, the source keeps scanning the path at runtime.
scan_intervalStringNo10SOnly used when discovery_mode=continuous. Scan interval for periodic discovery.
start_modeStringNoearliestOnly used when discovery_mode=continuous. Supported values: earliest (default), latest.
sync_modeStringNofullFile sync mode. Supported values: full, update. When update, only reads new/changed files (currently only supports binary format).
target_pathStringNo-Only used when sync_mode=update. Target base path used for comparison.
target_hadoop_confMapNo-Only used when sync_mode=update. Extra Hadoop configuration for target filesystem.
update_strategyStringNodistcpOnly used when sync_mode=update. Supported values: distcp (default), strict.
compare_modeStringNolen_mtimeOnly used when sync_mode=update. Supported values: len_mtime (default), checksum (only valid when update_strategy=strict).
update_compare_parallelismIntNo8Maximum parallelism for sparse target metadata lookups. Valid range: 1-64.
update_compare_bulk_thresholdIntNo0Switches comparison to directory listing when candidate count reaches the threshold. 0 disables.
post_sync_actionStringNononePost-sync action in discovery_mode=continuous. Supported values: none (default), delete, backup.
backup_pathStringNo-Backup destination base path when post_sync_action=backup. Must not overlap with path.
retention_max_ageStringNo-Optional retention age for backup files, only valid when post_sync_action=backup.
retention_check_intervalStringNo1HRetention scan interval, only effective when post_sync_action=backup and retention_max_age is configured.
recursive_file_scanBooleanNotrueWhether to scan subdirectories recursively. If false, subdirectories will be ignored.
common-optionsNo-Source plugin common parameters, please refer to Source Common Options for details.

How to Create a SMB Data Synchronization Job​

The following example demonstrates how to create a data synchronization job that reads data from a SMB share and prints it on the local client:

# Set the basic configuration of the task to be performed
env {
parallelism = 1
job.mode = "BATCH"
}

# Create a source to connect to SMB
source {
SmbFile {
host = "192.168.1.100"
port = 445
user = seatunnel
password = pass
domain = "WORKGROUP"
share = "data"
path = "/reports/json"
file_format_type = "json"
plugin_output = "smb"
schema = {
fields {
c_string = string
c_boolean = boolean
c_int = int
c_bigint = bigint
c_float = float
c_double = double
c_date = date
c_timestamp = timestamp
}
}
}
}

# Console printing of the read SMB data
sink {
Console {
parallelism = 1
}
}

Multiple Table​

SmbFile {
tables_configs = [
{
schema {
table = "student"
fields {
name = string
age = int
}
}
path = "/data/student"
host = "192.168.1.100"
port = 445
user = seatunnel
password = pass
share = "data"
file_format_type = "parquet"
},
{
schema {
table = "teacher"
fields {
name = string
age = int
}
}
path = "/data/teacher"
host = "192.168.1.100"
port = 445
user = seatunnel
password = pass
share = "data"
file_format_type = "parquet"
}
]
}

Changelog​

next version​

New Features​

  • [Feature] Support SMB file connector (10753)