Repository navigation
fix(frontend): preserve CSV row boundaries in split OUTFILE - #29778
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
ce388ef to
9c87540
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review of 9c875407a4ee15d33026865dadf4f4b468279a9b against 908166384d32e378a72cc3b5ef9e7075603c4e81: approve. No blocking finding in all five changed files and their export/data-branch consumers.
The existing CSV encoder is the right owner of record-end offsets: quoted newlines cannot safely be rediscovered by splitting encoded bytes. Carrying those offsets through the existing ordered batch payload preserves one writer/order authority. hasCSVData has a distinct purpose from Rows/CurFileSize: a header is not data, and an accepted zero-byte record is still a row. It prevents empty leading/tail rotation while permitting one oversized record. Offsets are omitted for unlimited CSV, and the actual write/rotate operations still use the existing file/pipe owner.
Adversarial boundaries checked: header plus exact-fit/oversized row, embedded newline/comma, empty records around an oversized record and across batches, out-of-order completion, and first write after rotation. These map to the real-file CSV-parser tests, batch-distribution comparison, and ordered final drain. Write/close/open failure tests preserve completed per-file progress without marking a partially written batch complete; call-site tracing confirms errors terminate the export rather than retrying the whole partial batch. The data-branch final-drain path reaches the same batch writer. JSONLINE dispatch bypasses CSV metadata and Parquet keeps its existing finalizer.
Evidence reused: the exact-head author records full frontend UT, the 12 focused race tests, and two same-service 23/23 SQL/BVT runs. Exact-head CI 37912137865 succeeds; whitespace check passes. The three-row BVT verifies file names/sizes, reloads every file and checks exact ordered values and cleanup. No earlier substantive review comments exist. No additional broad rerun was needed after mapping these cases to the changed boundaries.
Scope/quality: implementation +85/-10 across two files; tests/BVT +548/-0 across three files; no documentation-file delta. Tests have distinct behavioral or failure oracles, without sleeps or large fixtures. Finite splitting adds a linear row-offset scan and one offset per row, but coalesces records into writes; unlimited CSV avoids that allocation/scan. The disclosed microbenchmarks do not establish end-to-end throughput, and the noisy unlimited-CSV CPU samples do not justify claiming a CPU improvement.
Merge Queue Status
This pull request spent 17 minutes 58 seconds in the queue, with no time running CI. ReasonPull request #29778 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
HintYou should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. Waiting for any of
All conditions
Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
Closes #29761
What this PR does / why we need it:
CSV
SELECT ... INTO OUTFILE ... SPLITSIZEmust split at complete record boundaries. The writer now carries row counts and collects row-end offsets only when a finite size limit requires them. It greedily groups records that fit, includes the first record after rotation in the new file's write, and keeps a single oversized record intact. Unlimited CSV keeps one whole-batch write, while JSONLINE and Parquet behavior stays unchanged. The ordered export and data-branch consumers use the same payload metadata. Empty encoded records remain counted without creating empty tail files, and write or rotation failures preserve completed progress.Validation on base
908166384d32e378a72cc3b5ef9e7075603c4e81, head9c875407a4ee15d33026865dadf4f4b468279a9b:./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/frontend— passed (24.386s package time)../.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 -timeout=10m -run '^(Test_writeToCSVFile|TestExportCSVBatchSplitPreservesRows|TestExportCSVEmptyEncodedRecordDoesNotCreateTrailingFile|TestExportCSVBatchSplitExactFitAndOversizedRecord|TestExportCSVFinalDrainPreservesOutOfOrderBatchMetadata|TestExportCSVUnlimitedBatchUsesSingleWrite|TestConstructByteOmitsRowOffsetsWhenCSVIsUnlimited|TestExportCSVFiniteSplitGroupsRowsIntoOneWrite|TestExportCSVFiniteSplitCoalescesRowsAfterRotation|TestExportCSVBatchSplitsAreIndependentOfBatchDistribution|TestExportCSVBatchWriteErrorPreservesCompletedProgress|TestExportCSVRotationErrorsPreserveCompletedProgress)$' ./pkg/frontend— 12 focused tests passed (4.031s)..golangci.ymland golangci-lint v2.14.0 —0 issues.CGO_ENABLED=1 GOWORK=off go vet -mod=readonly ./pkg/frontendwith the repository CGo include/link/runtime paths — passed without diagnostics.make build-with-prebuilt-native— passed using verified, platform-matched native artifacts.test/distributed/cases/stage/issue_29761_splitsize.sql— two runs on the same task-owned service passed 23/23 statements each. The case verifies three 48-byte split files, ordered payload values, and cleanup.The 8,192-row producer benchmark measured 65,541 fewer B/op (−2.53%) for unlimited CSV. A spy writer reduced the 32 KiB case from 19 data-write calls to 10 while retaining 9 rotations; this spy does not measure pipe, file-open, or storage I/O. A five-sample finite-helper microbenchmark improved 31.7% at high limit and 38.3% at 32 KiB, but has no 95% confidence interval and measures helper CPU only. Earlier producer samples showed a possible unlimited-CSV CPU increase (+7.5% in the bounded reverse-order run; +17.3% in the initial paired run) while host load changed, so the measurements cannot attribute or rule out a small CPU regression. No end-to-end throughput improvement is claimed.
A single CSV record may exceed
SPLITSIZEso its contents remain intact. Full repository CI has not been run locally.