Skip to content

fix parquet outfile round trips and splitting - #29804

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/parquet-outfile-29762-29788
Oct 11, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
iamlinjunhong:fix/parquet-outfile-29762-29788

Conversation

@iamlinjunhong

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29762
issue #29763
issue #29780
issue #29781
issue #29782
issue #29784
issue #29785
issue #29786
issue #29787
issue #29788

What this PR does / why we need it:

  • Flushes Parquet row groups before SPLITSIZE checks and splits a large executor batch row by row while preserving non-empty files and aggregate rows.
  • Preserves unsigned BIGINT and BIT values as decimal text, restores SET member names, and supports VECF32, VECF64, and YEAR round trips.
  • Stores TIMESTAMP as adjusted-UTC Parquet microseconds for session-time-zone-independent LOAD round trips.
  • Creates readable empty Parquet output, rejects duplicate aliases deterministically, and isolates stage URL paths across repeated exports.
  • Adds frontend, LOAD mapper, stage cache, and distributed stage regression coverage.

Validation:

  • GOWORK=off go test -mod=readonly -count=1 ./pkg/frontend
  • GOWORK=off go test -mod=readonly -count=1 ./pkg/sql/colexec/external
  • GOWORK=off go test -mod=readonly -count=1 ./pkg/stage/stageutil
  • GOWORK=off go vet -mod=readonly ./pkg/frontend ./pkg/sql/colexec/external ./pkg/stage/stageutil
  • Direct protocol execution of parquet_outfile_regression.sql against a clean service instance.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 9, 2026
@matrix-meow matrix-meow added the size/L Denotes a PR that changes [500,999] lines label Oct 9, 2026
@iamlinjunhong
iamlinjunhong force-pushed the fix/parquet-outfile-29762-29788 branch from 039af69 to 643bed8 Compare October 9, 2026 19:58
@iamlinjunhong
iamlinjunhong force-pushed the fix/parquet-outfile-29762-29788 branch from 6f72c35 to 45cfc88 Compare October 10, 2026 13:26
@iamlinjunhong
iamlinjunhong force-pushed the fix/parquet-outfile-29762-29788 branch from 45cfc88 to 2cddcbb Compare October 10, 2026 16:52

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 0e60dc299776d65183f61f8783a2cd54e6e16180 against merge-base 42d42546fd2c2b2449cb81cea47f81d300139753. Request changes: two confirmed correctness blockers, including a material Parquet output-size regression. All changed hunks and the ten linked issue contracts were reviewed; there were no previous substantive review comments to reconcile.

The ownership direction is generally sound: retain ExportConfig as the export lifecycle owner, reuse the existing type parsers, and isolate mutable URLs at the authoritative stage cache boundary. However, physical row-group flushing per row is the wrong splitting granularity, and reusing the numeric string-conversion helper changes SET's lexical semantics. The inline findings describe the concrete failures.

Closure Review outcome
Export -> split/finalize -> fileservice -> reader Blocker: 32,768 narrow rows fail with a 1 GiB split target; per-row row-group metadata also inflates files. Empty output, trailing split finalization, copied-batch cleanup and error ownership traced.
Type encoding -> Parquet mapping -> LOAD Blocker: legal leading-space SET members silently change bitmap. Unsigned decimal text, UTC timestamps, YEAR and vector formatter/parser compatibility traced.
Stage cache -> export/nonexport resolvers -> cleanup/retry URL copies preserve the existing cache owner and isolate mutation; no second cache or state machine introduced. Test-oracle issue below.
Tests/results Reviewed separately from implementation, including retention of the previously asserted stable stage catalog fields.

Validation: reused exact-head CI run 38128221401, including the execution artifact showing parquet_outfile_regression.sql 38/38 and stage_based_stage_columns.sql 176/176, with zero ignored/failed cases. Added independent temporary probes invoking production ExportConfig.Write with 8,192-row batches and a real Parquet reader, and the production SET mapper with a real Parquet page. The row-limit probe fails on this head and passes on the PR base; the ordinary SET control passes while the whitespace case returns wrong values. These were focused CGo-wrapper runs with matching native inputs and all differing Go sources overlaid to the reviewed revision; no full local server/BVT or TP throughput benchmark is claimed.

Test-quality follow-up: TestUrlToStageDefForExportDoesNotMutateCachedURL also passes when run with the unfixed base implementation. first, second, cached, and expected u can share the same mutable URL; comparing them after mutation does not detect pollution. Use immutable expected path strings, capture the first result before the next resolution, and exercise distinct filenames. The split unit test also reproduces the per-row loop instead of exercising ExportConfig.Write, which is why it misses the integration/library limit; cover the real entry and exact values around 32,767/32,768 rows while fixing the blocker. These are not additional production findings.

Change accounting: implementation 4 files +177/-40; Go tests 3 files +231/-3; SQL/results 4 files +191/-53; documentation 0. The fixes need bounded row-group work and preservation of the existing SET authority, not additional state machines or parallel parsing paths.

Comment thread pkg/frontend/export.go Resolved
Comment thread pkg/sql/colexec/external/parquet.go Resolved

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 1600f516981c912d1f82385b20d16d48413718fd against base/merge-base 5f94c8f88a469e0e5053668bfca89770481a9595: APPROVE. Both previous P1 findings and the test-oracle follow-up are closed; no new blocking finding after reviewing the complete current diff and its ownership/consumer paths.

The design keeps the existing owners: ExportConfig owns file rotation/finalization, ParquetWriter owns row-group accounting, SET retains the authoritative types.ParseSet parser, and StageLoadCatalog isolates its cached URL before returning a mutable copy. These are focused corrections to existing behavior, so a separate feature/refactor design document is not required. The three row-group counters each support a concrete bound or rotation decision; no parallel lifecycle or parsing implementation is introduced.

  • Splitting now accumulates row groups across executor batches, bounded by estimated value bytes or row count, and rotates using serialized bytes or the unchanged format row-group ceiling. The real ExportConfig.Write regression verifies every value at 32,767/32,768 rows, one row group and the same file size as the unsplit control. The small-target single-batch case verifies exact values and excludes empty trailing files. I also checked the dependency's page-buffer/flush behavior: output bytes are published at row-group flush, and rotation handles an exhausted byte budget before the next chunk.
  • SET bytes reach ParseSet without trimming. Plain and dictionary page tests cover distinct leading-space names, combinations, empty strings and NULL, with a numeric whitespace control. Existing validated loading and rollback remain shared. The public SQL round trip checks bitmaps [1,2,3,0,NULL].
  • The stage-cache regression now uses immutable expected paths, distinct filenames and a captured first-result value; it detects cache pollution instead of comparing aliases of the same mutated URL.

Unhappy paths traced include empty output, copied-batch ownership, finalization/write errors, no trailing split, unavailable schema/vector rejection, parser failure rollback and stage-cache reuse. No new goroutine, retry controller or shared cache was added. The existing full-file buffer and non-transactional already-published export files remain the scope's pre-existing limits. SPLITSIZE remains a target with indivisible-row/row-group/footer overshoot, rather than an exact byte cap. No general TP throughput claim is made.

Evidence reused from exact-head CI run 38136548424: UT/SCA and both BVT jobs passed. The downloaded pessimistic execution artifact selects parquet_outfile_regression.sql 46/46 (0.561s) and stage_based_stage_columns.sql 176/176 (1.717s), with zero ignored/failed cases. The author's matching-head package/static results and two runs of the public regression on the same service corroborate the focused contracts. No redundant local broad rerun was needed.

Implementation, tests and SQL/results were inspected separately; accounting: {'production': [261, 50], 'Go tests': [330, 3], 'SQL/results': [215, 53], 'docs': [0, 0]}. Stable stage catalog projections preserve previously asserted fields rather than hiding new failures. No production files edited; no subagents.

@mergify

mergify Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-11 13:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-11 13:42 UTC · at 69eb27b4d584497c6ea102d6cda1ac007b4110f2

This pull request spent 22 minutes 5 seconds in the queue, with no time running CI.

Reason

Pull request #29804 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.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You 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.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch had an error being deployed

1 failed deployment
ci — 69eb27b4 Deployed Oct 11, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants