You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "DanielLeens (via GitHub)" <gi...@apache.org> on 2026/04/20 06:56:12 UTC
Re: [PR] [Bug][file base] Csv header fixed ‘,’ [seatunnel]
DanielLeens commented on PR #10257:
URL: https://github.com/apache/seatunnel/pull/10257#issuecomment-4278481008
Hi @jiamin13579, thanks for catching this. I reviewed the PR locally on branch `seatunnel-review-10257`, with PR head `968220f01924bb04aeb601b07ea3a9f435b865af` and merge base `eebee8785ba366e6d23037287a024011195878ff`.
# What This PR Solves
- User pain point: CSV body rows respect `field_delimiter`, but the generated CSV header was always joined with a comma.
- Fix approach: `CsvWriteStrategy#enableWriteHeader()` now joins field names with `fieldDelimiter` instead of a hardcoded comma.
- One sentence: CSV header and CSV data rows now use the same delimiter.
Simple example: with `field_delimiter = "|"`, the old output could be `id,name,age` followed by `1|Alice|18`; after the fix, the header becomes `id|name|age`.
# 1. Code Change Review
## 1.1 Core Logic Analysis
The real runtime path is:
```text
User configures LocalFile Sink
-> file_format_type = "csv"
-> enable_header_write = true
-> field_delimiter = "|"
Sink initialization
-> new CsvWriteStrategy(fileSinkConfig)
-> this.fieldDelimiter = fileSinkConfig.getFieldDelimiter() [CsvWriteStrategy.java:74]
First write to a file
-> CsvWriteStrategy.write(row) [CsvWriteStrategy.java:95-114]
-> getOrCreateOutputStream(filePath) [L141-173]
-> creates FSDataOutputStream
-> enableWriteHeader(fsDataOutputStream) [L175-180]
-> String.join(fieldDelimiter, seaTunnelRowType.getFieldNames())
-> writes rowDelimiter
-> serializationSchema.serialize(...)
-> CsvSerializationSchema.builder().delimiter(fieldDelimiter) [L80-91]
```
Before:
```java
fsDataOutputStream.write(String.join(",", seaTunnelRowType.getFieldNames()).getBytes());
```
After:
```java
fsDataOutputStream.write(
String.join(fieldDelimiter, seaTunnelRowType.getFieldNames()).getBytes());
```
Key findings:
- The normal CSV Sink path does hit this change when `enable_header_write = true`.
- The fix is precise and correct.
- It does not change checkpoint, commit, file move, partition path, or data-row serialization behavior.
- The added E2E config does not yet assert the actual header content.
## 1.2 Compatibility Impact
Judgment: fully compatible.
No API, config name, default value, protocol, or serialization contract changes. Default comma-delimited CSV output remains the same. Non-comma header output is corrected to match the existing configuration contract.
## 1.3 Performance / Side Effects
No meaningful performance impact. Header generation still happens only once per output file.
## 1.4 Error Handling And Logs
No new error handling is introduced. Existing IO exception wrapping remains unchanged.
Issue 1: Current GitHub Build is failing and the detailed log has expired
- Location: GitHub Check `Build` / fork run `jiamin13579/seatunnel` `20743369425`
- Description: PR checks show `Build` failed. The check-run summary points to fork run `20743369425`, where the failed job is `Run / Code style`. I tried to fetch the log, but GitHub returned HTTP 410, so the detailed failure lines are no longer available. Local `git diff --check upstream/dev...HEAD` is clean, but that does not replace a green project code-style check.
- Risk: merge requirements are not currently satisfied.
- Suggested fix: rebase on current `dev` and rerun Build so the code-style result is fresh and green.
- Severity: Medium
Issue 2: The new E2E writes the file but does not verify the header delimiter
- Location: `seatunnel-e2e/seatunnel-connector-v2-e2e/connector-file-local-e2e/src/test/java/org/apache/seatunnel/e2e/connector/file/local/LocalFileIT.java:325`
- Description: the new config writes to `/tmp/csv_header/seatunnel` with `enable_header_write = true` and `field_delimiter = "|"`, but the test never reads that directory back or checks the first line. If the code regressed to `String.join(",")`, this E2E could still pass because the write job itself may succeed.
- Risk: the regression test does not actually protect the bug being fixed.
- Suggested fix: add a readback/assert step for `/tmp/csv_header/seatunnel`, or inspect the first line and verify it uses `|` rather than comma-separated field names.
- Severity: Medium
# 2. Code Quality
The Java code change is clean and minimal. The test coverage should be tightened so it fails if the delimiter regresses.
# 3. Architecture
This is a precise bug fix. CSV data rows already use `fieldDelimiter`; making the header use the same value is the right boundary and does not need a new abstraction.
# 4. Issue Summary
| # | Issue | Location | Severity |
|---|---|---|---|
| 1 | Current Build is failing and logs are expired | GitHub Check `Build` / fork run `20743369425` | Medium |
| 2 | Added E2E does not assert the header delimiter | `LocalFileIT.java:325` | Medium |
# 5. Merge Decision
### Conclusion: can merge after fixes
Blocking item:
- Issue 1: please rerun CI and get a green Build.
Recommended item:
- Issue 2: make the new E2E actually validate that the header uses `field_delimiter`.
Overall, the code fix is correct and low-risk. Once CI is green and the regression test verifies the header content, this should be ready to merge.
--
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