You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "Scorpio777888 (via GitHub)" <gi...@apache.org> on 2025/02/26 09:57:19 UTC

[PR] [Doc][Improve] support chinese [docs/zh/connector-v2/sink/S3File.md] [seatunnel]

Scorpio777888 opened a new pull request, #8849:
URL: https://github.com/apache/seatunnel/pull/8849

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
   If no, write 'No'.
   If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
   -->
   
   
   ### How was this patch tested?
   
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
   -->
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Doc][Improve] support chinese [docs/zh/connector-v2/sink/S3File.md] [seatunnel]

Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on code in PR #8849:
URL: https://github.com/apache/seatunnel/pull/8849#discussion_r1971502622


##########
docs/zh/connector-v2/sink/S3File.md:
##########
@@ -0,0 +1,501 @@
+# S3File
+
+> S3 文件 Sink 连接器
+
+## 支持的引擎
+
+> Spark<br/>
+> Flink<br/>
+> SeaTunnel Zeta<br/>
+
+## 主要特性
+
+- [x] [精确一次](../../concept/connector-v2-features.md)
+- [ ] [cdc](../../concept/connector-v2-features.md)
+- [x] [支持多表写入](../../concept/connector-v2-features.md)
+
+默认情况下,我们使用 2PC 提交来确保 `精确一次`。
+
+- [x] 文件格式类型
+  - [x] text
+  - [x] csv
+  - [x] parquet
+  - [x] orc
+  - [x] json
+  - [x] excel
+  - [x] xml
+  - [x] binary
+
+## 描述
+
+将数据输出到 AWS S3 文件系统。
+
+## 支持的数据源信息
+
+| 数据源 | 支持的版本 |
+|--------|------------|
+| S3     | 当前版本   |
+
+## 数据库依赖
+
+> 如果您使用 Spark/Flink,为了使用此连接器,您必须确保您的 Spark/Flink 集群已经集成了 Hadoop。测试的 Hadoop 版本为 2.x。
+>
+> 如果您使用 SeaTunnel引擎,当您下载并安装 SeaTunnel引擎时,它会自动集成 Hadoop jar 包。您可以在 `${SEATUNNEL_HOME}/lib` 下检查 jar 包以确认这一点。
+> 要使用此连接器,您需要将 `hadoop-aws-3.1.4.jar` 和 `aws-java-sdk-bundle-1.12.692.jar` 放在 `${SEATUNNEL_HOME}/lib` 目录下。
+
+## 数据类型映射
+
+如果写入 `csv`、`text` 文件类型,所有列都将为字符串类型。
+
+### Orc 文件类型
+
+| SeaTunnel 数据类型 | Orc 数据类型         |
+|--------------------|---------------------|
+| STRING             | STRING              |
+| BOOLEAN            | BOOLEAN             |
+| TINYINT            | BYTE                |
+| SMALLINT           | SHORT               |
+| INT                | INT                 |
+| BIGINT             | LONG                |
+| FLOAT              | FLOAT               |
+| FLOAT              | FLOAT               |
+| DOUBLE             | DOUBLE              |
+| DECIMAL            | DECIMAL             |
+| BYTES              | BINARY              |
+| DATE               | DATE                |
+| TIME <br/> TIMESTAMP | TIMESTAMP           |
+| ROW                | STRUCT              |
+| NULL               | 不支持的数据类型     |
+| ARRAY              | LIST                |
+| Map                | Map                 |
+
+### Parquet 文件类型
+
+| SeaTunnel 数据类型 | Parquet 数据类型     |
+|--------------------|---------------------|
+| STRING             | STRING              |
+| BOOLEAN            | BOOLEAN             |
+| TINYINT            | INT_8               |
+| SMALLINT           | INT_16              |
+| INT                | INT32               |
+| BIGINT             | INT64               |
+| FLOAT              | FLOAT               |
+| FLOAT              | FLOAT               |
+| DOUBLE             | DOUBLE              |
+| DECIMAL            | DECIMAL             |
+| BYTES              | BINARY              |
+| DATE               | DATE                |
+| TIME <br/> TIMESTAMP | TIMESTAMP_MILLIS    |
+| ROW                | GroupType           |
+| NULL               | 不支持的数据类型     |
+| ARRAY              | LIST                |
+| Map                | Map                 |
+
+## Sink 选项
+
+| 名称                                  | 类型    | 是否必填 | 默认值                                               | 描述                                                                                                                                                            |
+|---------------------------------------|---------|----------|-------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| path                                  | string  | 是       | -                                                     |                                                                                                                                                                |
+| tmp_path                              | string  | 否       | /tmp/seatunnel                                        | 结果文件将首先写入临时路径,然后使用 `mv` 将临时目录提交到目标目录。需要一个 S3 目录。                                                                           |
+| bucket                                | string  | 是       | -                                                     |                                                                                                                                                                |
+| fs.s3a.endpoint                       | string  | 是       | -                                                     |                                                                                                                                                                |
+| fs.s3a.aws.credentials.provider       | string  | 是       | com.amazonaws.auth.InstanceProfileCredentialsProvider | 认证 s3a 的方式。目前仅支持 `org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider` 和 `com.amazonaws.auth.InstanceProfileCredentialsProvider`。                  |
+| access_key                            | string  | 否       | -                                                     | 仅当 fs.s3a.aws.credentials.provider = org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider 时使用                                                             |
+| access_secret                         | string  | 否       | -                                                     | 仅当 fs.s3a.aws.credentials.provider = org.apache.hadoop.fs.s3a.SimpleAWSCredentialsProvider 时使用                                                             |
+| custom_filename                       | boolean | 否       | false                                                 | 是否需要自定义文件名                                                                                                                                           |
+| file_name_expression                  | string  | 否       | "${transactionId}"                                    | 仅当 custom_filename 为 true 时使用                                                                                                                            |
+| filename_time_format                  | string  | 否       | "yyyy.MM.dd"                                          | 仅当 custom_filename 为 true 时使用                                                                                                                            |
+| file_format_type                      | string  | 否       | "csv"                                                 |                                                                                                                                                                |
+| field_delimiter                       | string  | 否       | '\001'                                                | 仅当 file_format 为 text 时使用                                                                                                                                |
+| row_delimiter                         | string  | 否       | "\n"                                                  | 仅当 file_format 为 text 时使用                                                                                                                                |
+| have_partition                        | boolean | 否       | false                                                 | 是否需要处理分区。                                                                                                                                             |
+| partition_by                          | array   | 否       | -                                                     | 仅当 have_partition 为 true 时使用                                                                                                                             |
+| partition_dir_expression              | string  | 否       | "${k0}=${v0}/${k1}=${v1}/.../${kn}=${vn}/"            | 仅当 have_partition 为 true 时使用                                                                                                                             |
+| is_partition_field_write_in_file      | boolean | 否       | false                                                 | 仅当 have_partition 为 true 时使用                                                                                                                             |
+| sink_columns                          | array   | 否       |                                                       | 当此参数为空时,所有字段均为 sink 列                                                                                                                           |
+| is_enable_transaction                 | boolean | 否       | true                                                  |                                                                                                                                                                |
+| batch_size                            | int     | 否       | 1000000                                               |                                                                                                                                                                |
+| compress_codec                        | string  | 否       | none                                                  |                                                                                                                                                                |
+| common-options                        | object  | 否       | -                                                     |                                                                                                                                                                |
+| max_rows_in_memory                    | int     | 否       | -                                                     | 仅当 file_format 为 excel 时使用                                                                                                                               |
+| sheet_name                            | string  | 否       | Sheet${Random number}                                 | 仅当 file_format 为 excel 时使用                                                                                                                               |
+| csv_string_quote_mode                 | enum    | 否       | MINIMAL                                               | 仅当 file_format 为 csv 时使用                                                                                                                                 |
+| xml_root_tag                          | string  | 否       | RECORDS                                               | 仅当 file_format 为 xml 时使用,指定 XML 文件中根元素的标签名称。                                                                                               |
+| xml_row_tag                           | string  | 否       | RECORD                                                | 仅当 file_format 为 xml 时使用,指定 XML 文件中数据行的标签名称。                                                                                               |
+| xml_use_attr_format                   | boolean | 否       | -                                                     | 仅当 file_format 为 xml 时使用,指定是否使用标签属性格式处理数据。                                                                                              |
+| single_file_mode                      | boolean | 否       | false                                                 | 每个并行度只会输出一个文件。当此参数开启时,batch_size 将不会生效。输出文件名不会有文件块后缀。                                                                 |
+| create_empty_file_when_no_data        | boolean | 否       | false                                                 | 当上游没有数据同步时,仍然会生成相应的数据文件。                                                                                                               |
+| parquet_avro_write_timestamp_as_int96 | boolean | 否       | false                                                 | 仅当 file_format 为 parquet 时使用                                                                                                                             |
+| parquet_avro_write_fixed_as_int96     | array   | 否       | -                                                     | 仅当 file_format 为 parquet 时使用                                                                                                                             |
+| hadoop_s3_properties                  | map     | 否       |                                                       | 如果您需要添加其他选项,可以在此处添加,并参考此[链接](https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html)                            |
+| schema_save_mode                      | Enum    | 否       | CREATE_SCHEMA_WHEN_NOT_EXIST                          | 在开启同步任务之前,对目标路径进行不同的处理                                                                                                                   |
+| data_save_mode                        | Enum    | 否       | APPEND_DATA                                           | 在开启同步任务之前,对目标路径中的数据文件进行不同的处理                                                                                                       |
+| enable_header_write                   | boolean | 否       | false                                                 | 仅当 file_format_type 为 text,csv 时使用。<br/> false: 不写入表头, true: 写入表头。                                                                             |
+| encoding                              | string  | 否       | "UTF-8"                                               | 仅当 file_format_type 为 json,text,csv,xml 时使用。                                                                                                             |
+
+### path [string]
+
+存储数据文件的路径,支持变量替换。例如:path=/test/${database_name}/${schema_name}/${table_name}
+
+### hadoop_s3_properties [map]
+
+如果您需要添加其他选项,可以在此处添加,并参考此[链接](https://hadoop.apache.org/docs/stable/hadoop-aws/tools/hadoop-aws/index.html)
+
+```
+hadoop_s3_properties {
+      "fs.s3a.buffer.dir" = "/data/st_test/s3a"
+      "fs.s3a.fast.upload.buffer" = "disk"
+   }
+```
+
+### custom_filename [boolean]
+
+是否自定义文件名
+
+### file_name_expression [string]
+
+仅当 `custom_filename` 为 `true` 时使用
+
+`file_name_expression` 描述了将创建到 `path` 中的文件表达式。我们可以在 `file_name_expression` 中添加变量 `${now}` 或 `${uuid}`,例如 `test_${uuid}_${now}`,
+`${now}` 表示当前时间,其格式可以通过指定选项 `filename_time_format` 来定义。
+
+请注意,如果 `is_enable_transaction` 为 `true`,我们会在文件头部自动添加 `${transactionId}_`。
+
+### filename_time_format [string]
+
+仅当 `custom_filename` 为 `true` 时使用
+
+当 `file_name_expression` 参数中的格式为 `xxxx-${now}` 时,`filename_time_format` 可以指定路径的时间格式,默认值为 `yyyy.MM.dd`。常用的时间格式如下:
+
+| 符号 | 描述               |
+|------|--------------------|
+| y    | 年                 |
+| M    | 月                 |
+| d    | 日                 |
+| H    | 小时 (0-23)        |
+| m    | 分钟               |
+| s    | 秒                 |
+
+### file_format_type [string]
+
+我们支持以下文件类型:
+
+`text` `csv` `parquet` `orc` `json` `excel` `xml` `binary`
+
+请注意,最终文件名将以文件格式类型的后缀结尾,文本文件的后缀为 `txt`。
+
+### field_delimiter [string]
+
+行数据中列之间的分隔符。仅在 `text` 文件格式中需要。
+
+### row_delimiter [string]
+
+文件中行之间的分隔符。仅在 `text` 文件格式中需要。
+
+### have_partition [boolean]
+
+是否需要处理分区。
+
+### partition_by [array]
+
+仅当 `have_partition` 为 `true` 时使用。
+
+根据选定的字段对数据进行分区。
+
+### partition_dir_expression [string]
+
+仅当 `have_partition` 为 `true` 时使用。
+
+如果指定了 `partition_by`,我们将根据分区信息生成相应的分区目录,最终文件将放置在分区目录中。
+
+默认的 `partition_dir_expression` 为 `${k0}=${v0}/${k1}=${v1}/.../${kn}=${vn}/`。`k0` 是第一个分区字段,`v0` 是第一个分区字段的值。
+
+### is_partition_field_write_in_file [boolean]
+
+仅当 `have_partition` 为 `true` 时使用。
+
+如果 `is_partition_field_write_in_file` 为 `true`,分区字段及其值将被写入数据文件。
+
+例如,如果您想写入 Hive 数据文件,其值应为 `false`。
+
+### sink_columns [array]
+
+哪些列需要写入文件,默认值为从 `Transform` 或 `Source` 获取的所有列。
+字段的顺序决定了文件实际写入的顺序。
+
+### is_enable_transaction [boolean]
+
+如果 `is_enable_transaction` 为 true,我们将确保在将数据写入目标目录时不会丢失或重复。
+
+请注意,如果 `is_enable_transaction` 为 `true`,我们会在文件头部自动添加 `${transactionId}_`。
+
+目前仅支持 `true`。
+
+### batch_size [int]
+
+文件中的最大行数。对于 SeaTunnel Engine,文件中的行数由 `batch_size` 和 `checkpoint.interval` 共同决定。如果 `checkpoint.interval` 的值足够大,sink writer 将一直写入文件,直到文件中的行数超过 `batch_size`。如果 `checkpoint.interval` 较小,sink writer 将在新的 checkpoint 触发时创建一个新文件。
+
+### compress_codec [string]
+
+文件的压缩编解码器,支持的详细信息如下:
+
+- txt: `lzo` `none`
+- json: `lzo` `none`
+- csv: `lzo` `none`
+- orc: `lzo` `snappy` `lz4` `zlib` `none`
+- parquet: `lzo` `snappy` `lz4` `gzip` `brotli` `zstd` `none`
+
+提示:excel 类型不支持任何压缩格式
+
+### common options
+
+Sink 插件通用参数,请参考 [Sink 通用选项](../sink-common-options.md) 获取详细信息。
+
+### max_rows_in_memory [int]
+
+当文件格式为 Excel 时,内存中可以缓存的最大数据项数。
+
+### sheet_name [string]
+
+写入工作表的名称
+
+### csv_string_quote_mode [string]
+
+当文件格式为 CSV 时,CSV 的字符串引用模式。
+
+- ALL: 所有字符串字段都会被引用。
+- MINIMAL: 引用包含特殊字符的字段,如字段分隔符、引用字符或行分隔符字符串中的任何字符。
+- NONE: 从不引用字段。当数据中出现分隔符时,打印机会在其前面加上转义字符。如果未设置转义字符,格式验证将抛出异常。
+
+### xml_root_tag [string]
+
+指定 XML 文件中根元素的标签名称。
+
+### xml_row_tag [string]
+
+指定 XML 文件中数据行的标签名称。
+
+### xml_use_attr_format [boolean]
+
+指定是否使用标签属性格式处理数据。
+
+### parquet_avro_write_timestamp_as_int96 [boolean]
+
+支持将时间戳写入 Parquet INT96,仅对 parquet 文件有效。
+
+### parquet_avro_write_fixed_as_int96 [array]
+
+支持将 12 字节字段写入 Parquet INT96,仅对 parquet 文件有效。

Review Comment:
   ```suggestion
   支持将 12-byte 字段写入 Parquet INT96,仅对 parquet 文件有效。
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [Doc][Improve] support chinese [docs/zh/connector-v2/sink/S3File.md] [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X merged PR #8849:
URL: https://github.com/apache/seatunnel/pull/8849


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org