Repository navigation
fix(export): reject JSONLINE export with duplicate column names instead of silently dropping values (#30703) - #30807
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? |
|
Exact-head evidence for Live end-to-end on the branch binary (docker single-process instance built from this head): Duplicated-alias CSV export keeps both columns (positional writer untouched by this change). |
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: dca0d807b3a3f382aaa8635716bc23216de18046
Assessment: request_changes
Reviewed the complete two-file delta and export lifecycle. Rejecting duplicates in the shared JSON writer is reasonable, but the empty-string sentinel leaves a reachable silent-data-loss case unresolved.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
- P2
pkg/frontend/export.go:1387: Export SELECT NAME_CONST('', 11), NAME_CONST('', 22) INTO OUTFILE '/tmp/duplicate_empty.jsonl' FORMAT 'jsonline'. Both resolved column names are empty strings.
Impact: The helper returns the repeated empty name, which this condition interprets as no duplicate. Serialization therefore discards 11 and retains only {"":22}. An empty duplicate also hides later nonempty duplicates. Return an explicit found boolean or error, and cover these cases in regression tests.
Evidence: NameConstHeading and the result-metadata path preserve empty names; NAME_CONST validation accepts them. A verbatim-helper probe passed the ordinary-name control but failed both empty-name rejection tests, reproducing the overwrite. See duplicate-probe.log and checks/1792657183717105357-3.json (exit 1).
Validation:
-
Isolation preflight passed. The standard-library-only helper probe ran through the supplied test-exec with the assigned caches.
-
git diff --check passed; receipt checks/1792657257900381834-3.json matches the assigned clean HEAD and diff-check.log.
-
Frozen exact-head CI records successful UT, SCA, build and substantive BVT jobs. Existing tests omit the demonstrated boundary.
-
Full review and probe provenance retained under /home/xupeng/.local/state/mo-bot/jobs/f36284542f4b3bb8b3db1a37/attempt-1/review-evidence.json.
Limitations:
-
The probe executes the extracted helper, not the frontend. SQL reachability was established by source tracing; no live SQL or native package tests were rerun.
-
local_validation was empty; raw CI and author-reported live-test logs were unavailable.
-
No benchmark was run. Added work is one temporary map and column scan per JSON batch; other export formats and ordinary SQL paths are unchanged.
|
CI follow-up note: the first attempt of |
|
Addressed the empty-name P2 from review 5611254397 in commit
The writer regression exercises ordinary duplicates, two empty names, empty duplicates before later nonempty duplicates, unique nonempty names, and a single empty name. It checks that rejected batches emit no output bytes, accepted batches retain all values, and the memory pool is balanced on both paths. Both empty-duplicate cases failed against the original production code before the fix. Local validation on the final source:
The previous head's required CI was green. This push starts a separate CI run; these local results do not claim that the new CI has finished. Please re-review the correction. |
|
Re-reviewed head The empty-name P2 in review 5611254397 is addressed: duplicate detection now returns an explicit found boolean, so two empty names cannot be mistaken for no duplicate or hide subsequent duplicate names. A single empty name remains accepted. The writer rejects before serializing any rows, reports the error through the existing batch channel, and retains deferred batch cleanup. The consumer checks the error before attempting index ordering, so this error result does not need a batch index to propagate correctly. CSV/Parquet dispatch is unchanged. The added writer tests cover ordinary duplicates, repeated empty names, empty duplicates preceding other duplicates, unique names and a single empty name; they check error/no emitted bytes or exact retained values, plus balanced memory-pool usage. Validation: |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: dd8c208144f83bfc2a329f1081e1aae80b85d531
Assessment: approve
Reviewed the complete three-file delta and affected callers. The JSONLINE encoder correctly rejects duplicate names, including empty names, through existing error and cleanup paths. Rejecting ambiguous output avoids silently renaming columns or changing the format. Account cleanup now closes tenant sessions before deletion while preserving the admin connection. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Frozen exact-head evidence reports successful Linux UT, SCA, coverage and BVT checks.
-
Isolation preflight passed; native build provenance matched 194 current inputs and 63 retained artifacts.
-
Eight public SQL diagnostic cases passed under -race: duplicate and empty names return error 20301 without publishing a file; valid names, inferred format, CSV preservation and session reuse behaved correctly.
-
TestPrivilegeCacheTracksRemoteCatalogChanges passed under -race once, then twice in one process, including account-removal assertions and shared-cluster reuse.
-
Reconciled command, clean-source fingerprint, exit receipts and terminal logs. Evidence manifest: /home/xupeng/.local/state/mo-bot/jobs/89fe3bb83ca09b37b9a03ecc/attempt-1/review-evidence.json. Source remained unchanged.
Limitations:
-
Public SQL diagnostics used a test-only overlay; full CI was not rerun locally.
-
The historical slow cleanup failure was not reproduced locally.
-
No throughput benchmark was run. Added work is one O(column-count) temporary set per JSONLINE batch; ordinary SQL, CSV and parquet execution paths are unchanged.
Merge Queue Status
This pull request spent 1 hour 15 minutes 32 seconds in the queue, with no time running CI. ReasonThe merge conditions cannot be satisfied due to failing checks
HintYou may have to fix your CI before adding the pull request to the queue again. 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:
Fixes #30703
What this PR does / why we need it:
SELECT ... INTO OUTFILE ... FORMAT 'jsonline'built each row as amap[string]interface{}keyed by the output column names. When two SELECTaliases collide, the later column overwrote the earlier one on every row and
the export still returned success — silently dropping data (issue's example:
SELECT a AS x, b AS xproduced only{"x":22}/{"x":44}).A JSON object cannot carry duplicate member names, so the export now fails
fast before any row is written:
constructJSONLinechecks the resolved columnnames up front and rejects duplicates with
invalid input: jsonline export cannot write duplicate column names ('x'); give every output column a unique alias.CSV and parquet exports are untouched (they are positional, both duplicated
aliases keep both columns).
Validation
pkg/frontend/export_test.go: helper-levelTestDuplicatedJSONLineColumnand end-to-endTestJSONLineExportRejectsDuplicateAliases(batch throughconstructJSONLine, asserts an error carryingduplicate column namesreaches the batch channel and no bytes are emitted).
name and a fix hint; no output file is created;
{"x":11,"x2":22}/{"x":33,"x2":44};JSONLINE-only), matching pre-change CSV behavior.