You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "corgy-w (via GitHub)" <gi...@apache.org> on 2025/01/22 09:29:19 UTC
[PR] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
corgy-w opened a new pull request, #8572:
URL: https://github.com/apache/seatunnel/pull/8572
<!--
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
User selects csv string pattern
<!-- 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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572#discussion_r1926400564
##########
seatunnel-formats/seatunnel-format-csv/src/main/java/org/apache/seatunnel/format/csv/CsvSerializationSchema.java:
##########
@@ -63,14 +64,16 @@ private CsvSerializationSchema(
DateTimeUtils.Formatter dateTimeFormatter,
TimeUtils.Formatter timeFormatter,
Charset charset,
- String nullValue) {
+ String nullValue,
+ String quoteMode) {
Review Comment:
```suggestion
CsvStringQuoteMode quoteMode) {
```
--
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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 merged PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572
--
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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572#discussion_r1926452506
##########
docs/en/connector-v2/sink/S3File.md:
##########
@@ -119,6 +119,7 @@ If write to `csv`, `text` file type, All column will be string.
| common-options | object | no | - | |
| max_rows_in_memory | int | no | - | Only used when file_format is excel. |
| sheet_name | string | no | Sheet${Random number} | Only used when file_format is excel. |
+| csv_string_quote_mode | string | no | MINIMAL | Only used when file_format is csv. |
Review Comment:
```suggestion
| csv_string_quote_mode | enum | no | MINIMAL | Only used when file_format is csv. |
```
##########
docs/en/connector-v2/sink/S3File.md:
##########
@@ -503,18 +514,19 @@ Only used when file_format_type is text,csv.false:don't write header,true:write
### 2.3.0 2022-12-30
-- [BugFix] Fixed the following bugs that failed to write data to files ([3258](https://github.com/apache/seatunnel/pull/3258))
- - When field from upstream is null it will throw NullPointerException
- - Sink columns mapping failed
- - When restore writer from states getting transaction directly failed
+- [BugFix] Fixed the following bugs that failed to write data to
+ files ([3258](https://github.com/apache/seatunnel/pull/3258))
+ - When field from upstream is null it will throw NullPointerException
+ - Sink columns mapping failed
+ - When restore writer from states getting transaction directly failed
- [Feature] Support S3A protocol ([3632](https://github.com/apache/seatunnel/pull/3632))
- - Allow user to add additional hadoop-s3 parameters
- - Allow the use of the s3a protocol
- - Decouple hadoop-aws dependencies
+ - Allow user to add additional hadoop-s3 parameters
+ - Allow the use of the s3a protocol
+ - Decouple hadoop-aws dependencies
- [Improve] Support setting batch size for every file ([3625](https://github.com/apache/seatunnel/pull/3625))
- [Feature]Set S3 AK to optional ([3688](https://github.com/apache/seatunnel/pull/))
### Next version
-- [Improve] Support file compress ([3899](https://github.com/apache/seatunnel/pull/3899))
+- [Improve] Support file compress ([3899](https://github.com/apache/seatunnel/pull/3899))
Review Comment:
Let's delete this part.
##########
docs/zh/connector-v2/sink/HdfsFile.md:
##########
@@ -63,6 +63,7 @@
| kerberos_keytab_path | string | 否 | - | kerberos 的 keytab 路径 |
| compress_codec | string | 否 | none | 压缩编解码器 |
| common-options | object | 否 | - | 接收器插件通用参数,请参阅 [接收器通用选项](../sink-common-options.md) 了解详情 |
+| csv_string_quote_mode | string | 否 | MINIMAL | 仅在文件格式为 CSV 时使用。 |
Review Comment:
where is it description?
##########
seatunnel-formats/seatunnel-format-csv/src/test/java/org/apache/seatunnel/format/csv/CsvTextFormatSchemaTest.java:
##########
@@ -148,24 +152,37 @@ public void testParse() throws IOException {
.delimiter(",")
.build();
+ CsvSerializationSchema csvSerializationSchemaWithAllQuotes =
+ CsvSerializationSchema.builder()
+ .seaTunnelRowType(seaTunnelRowType)
+ .dateTimeFormatter(Formatter.YYYY_MM_DD_HH_MM_SS_SSSSSS)
+ .delimiter(",")
+ .quoteMode(CsvStringQuoteMode.ALL)
Review Comment:
Please test other option value too.
--
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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572#discussion_r1926296638
##########
seatunnel-formats/seatunnel-format-csv/src/main/java/org/apache/seatunnel/format/csv/CsvSerializationSchema.java:
##########
@@ -86,6 +89,7 @@ public static class Builder {
private TimeUtils.Formatter timeFormatter = TimeUtils.Formatter.HH_MM_SS;
private Charset charset = StandardCharsets.UTF_8;
private String nullValue = "";
+ private String quoteMode = "MINIMAL";
Review Comment:
use enum?
--
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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572#discussion_r1944071549
##########
docs/zh/connector-v2/sink/HdfsFile.md:
##########
@@ -181,10 +182,19 @@ HdfsFile {
is_enable_transaction = true
}
```
+
### enable_header_write [boolean]
仅在 file_format_type 为 text,csv 时使用。false:不写入表头,true:写入表头。
+### csv_string_quote_mode [string]
+
+当文件格式为 CSV 时,CSV 的字符串引号模式。
+
+- ALL:所有字符串字段都会加引号。
+- MINIMAL:仅为包含特殊字符(如字段分隔符、引号字符或行分隔符字符串中的任何字符)的字段加引号。
+- NONE:从不为字段加引号。当数据中包含分隔符时,打印机会在前面加上转义字符。如果未设置转义字符,则格式验证会抛出异常。
Review Comment:
```suggestion
- NONE:从不为字段加引号。当数据中包含分隔符时,输出会在前面加上转义字符。如果未设置转义字符,则格式验证会抛出异常。
```
##########
docs/en/connector-v2/sink/LocalFile.md:
##########
@@ -33,18 +33,18 @@ By default, we use 2PC commit to ensure `exactly-once`
## Options
-| Name | Type | Required | Default | Description |
-|---------------------------------------|---------|----------|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| path | string | yes | - | |
-| tmp_path | string | no | /tmp/seatunnel | The result file will write to a tmp path first and then use `mv` to submit tmp dir to target dir. |
-| custom_filename | boolean | no | false | Whether you need custom the filename |
-| file_name_expression | string | no | "${transactionId}" | Only used when custom_filename is true |
-| filename_time_format | string | no | "yyyy.MM.dd" | Only used when custom_filename is true |
-| file_format_type | string | no | "csv" | |
-| field_delimiter | string | no | '\001' | Only used when file_format_type is text |
-| row_delimiter | string | no | "\n" | Only used when file_format_type is text |
-| have_partition | boolean | no | false | Whether you need processing partitions. |
-| partition_by | array | no | - | Only used then have_partition is true |
+gi t| Name | Type | Required | Default | Description |
Review Comment:
```suggestion
| Name | Type | Required | Default | Description |
```
##########
docs/zh/connector-v2/sink/LocalFile.md:
##########
@@ -176,6 +177,14 @@ Sink 插件的常见参数,请参阅 [Sink 常见选项](../sink-common-option
工作簿的表名。
+### csv_string_quote_mode [string]
+
+当文件格式为 CSV 时,CSV 的字符串引号模式。
+
+- ALL:所有字符串字段都会加引号。
+- MINIMAL:仅为包含特殊字符(如字段分隔符、引号字符或行分隔符字符串中的任何字符)的字段加引号。
+- NONE:从不为字段加引号。当数据中包含分隔符时,打印机会在前面加上转义字符。如果未设置转义字符,则格式验证会抛出异常。
Review Comment:
```suggestion
- NONE:从不为字段加引号。当数据中包含分隔符时,输出会在前面加上转义字符。如果未设置转义字符,则格式验证会抛出异常。
```
--
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] [Fix][Connector-V2] User selects csv string pattern [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on PR #8572:
URL: https://github.com/apache/seatunnel/pull/8572#issuecomment-2638925639
waiting for ci passed
--
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