Skip to content

fix: preserve BIT values when loading JSONLINE - #32759

Merged
mergify[bot] merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-30653
Nov 15, 2026
Merged

mergify[bot] merged 2 commits into
matrixorigin:mainfrom
aptend:fix/astra-meow-30653

Conversation

@aptend

@aptend aptend commented Nov 15, 2026 •

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:

Fixes #30653

What this PR does / why we need it:

Loading numeric JSONLINE fields into BIT previously interpreted the decimal digits as raw bytes: 1 became 49, and narrow or large values could not reload correctly. This completes the JSONLINE half of #30653; the CSV half was fixed in #30655.

  • Preserve JSON NUMBER provenance for object and array fields, then convert canonical nonnegative uint64 values before direct BIT construction and the staged varchar-to-BIT cast. Zero, narrow values, 2^53+1 and UINT64_MAX retain their exact values.
  • Match NULLIF against the raw field before numeric conversion. Quoted strings, JSON null, CSV and Kafka retain their existing behavior; the OUTFILE exporter is unchanged.

Validation:

  • Native regression tests reproduce 32 failing subtests on the original source (RED exit 1), then pass 8 top-level tests and 49 subtests. Full external/csvparser package tests and frontend CSV/saved-result plus plan NULLIF guards pass with the CGO/native test wrapper.
  • make static-check-selected STATIC_CHECK_PACKAGES="./pkg/sql/util/csvparser ./pkg/sql/colexec/external" passed with 0 issues.
  • One real native foreground run completed normal MoTester method=run with full metadata: 36/36 SQL statements passed, error.txt was empty, and the console contained no hidden SQLException. Independent byte/JSON-kind checks verified both BIT JSONLINE exports, including saved query results, followed by successful reloads.
  • A typed PyMySQL LOAD of the out-of-width JSON numeric value 256 into BIT(8) retained error 20101/HY000. The same connection then completed SELECT 1 and a valid two-row LOAD; cursors, connections, owned databases, service/client processes and planned ports were cleaned.
  • Public SQL coverage uses small serial and compressed inputs. Native unit tests exercise the actual staged varchar-to-BIT consumer.

A JSONLINE numeric field loaded into BIT previously reached the BIT
consumer as raw digit bytes (e.g. 1 became 0x31/49), rejected narrow
values and mishandled high magnitudes such as 2^53+1. Keep the canonical
unsigned integer JSON NUMBER kind and value for object and array
containers through both the direct and staged varchar->BIT consumers,
apply the JSON NULLIF against the raw field before conversion, and keep
zero, narrow BIT and 2^53+1..UINT64_MAX exact. Quoted values, raw text,
NULL, CSV and Kafka byte behavior are unchanged; JSONLINE OUTFILE export
already emits canonical numbers. The remaining CSV half of the issue was
fixed separately (matrixorigin#30655).

Fixes matrixorigin#30653
@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 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 5b4aae1329572226815ebb2d588f11d699ec4cef

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 5b4aae1329572226815ebb2d588f11d699ec4cef

Assessment: approve

The fix preserves exact numeric JSONLINE BIT values through both existing consumers while retaining raw NULLIF, string, CSV and Kafka semantics. The bounded provenance conversion adds little complexity. No actionable defects remain.

Model: gpt-6.1-sol / max

Session: 01a1a004-90c3-73b1-acc9-3d4636452003 · slot 0 · generation 0

Validation:

  • Reviewed the complete delta, relevant consumers, linked issue history and all three discussion entries; saved discussion-assessment.json.

  • Reused frozen-head successful UT, SCA, Compose PROXY BVT and COMPOSE PESSIMISTIC BVT evidence.

  • Local isolated helper probe passed 62,001 values across BIT widths 1–64 plus rejection controls; retained lexeme-probe.log.

  • Source/fixture audit passed all 12 artifacts, gzip identity, 36 SQL statements, 10 result tables and metadata. Four local receipts and logs are matched in validation-reconciliation.json.

Limitations:

  • Native packages and service BVT were not rerun locally; installed Go 1.26.6 is below the required 1.27.1. Native validation relies on frozen CI and attributed author reports; raw author logs were not supplied.

  • Public coverage uses small serial and compressed inputs; staged parallel conversion is covered by native unit tests.

@mergify mergify Bot added the queued label Nov 15, 2026
@mergify

mergify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as c71e0c6 at 06:26 UTC

1 h 7 min in the queue, 1 h 6 min of it CI.

So far

  • ✅ Entered the queue Sun 15 Nov, 05:19 · rule main · triggered by rule Automatic queue on approval for main
  • ✅ Passed · in place
  • ✅ Merged 06:26 · c71e0c6 · squash
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection
  • any of · required by GitHub branch protection:
    • check-success = CI Required
    • check-neutral = CI Required
    • check-skipped = CI Required

Times in UTC · dashboard · how the merge queue works

This branch was previously deployed

1 inactive deployment
ci — 692be578 Deployed Nov 15, 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.

[Bug]: MODUMP QUERY_RESULT exports BIT as decimal text, causing wrong values after LOAD DATA round-trip

3 participants