Skip to content

Fix Kafka JSONL projection and message metadata scans - #30695

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/issue-29856-kafka-json-projection
Oct 21, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
jiangxinmeng1:codex/issue-29856-kafka-json-projection

Conversation

@jiangxinmeng1

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 #29856

What this PR does / why we need it:

Kafka JSONL object scans currently size parsed fields from the projected columns. In strict SQL mode, a valid two-column message fails when only the first column or __mo_message_id is selected because row validation compares that shortened slice with the full declared column count. In non-strict mode, the short-row path emits NULL for synthetic metadata.

Validate each Kafka JSON object against the declared data-column count before materialization. For Kafka JSONL, materialize the projected data fields and synthetic metadata directly; the physical field slice no longer stands in for the full record width. This keeps allocations proportional to the projection, including metadata-only scans of wide tables. CSV and ordinary JSONL row handling retain their existing paths.

Regression coverage exercises full, first-column, later-column, and message-ID projections through SQL in strict and non-strict modes, a CSV control, and focused fake-Kafka checks for short objects and the pending-offset failure path. The pre-fix focused test reproduced the strict error and non-strict NULL offset.

Validation on the final diff:

  • Local: mo-cgo-test -count=1 -timeout=240s ./pkg/sql/colexec/external (full package)
  • Local: go vet -mod=readonly ./pkg/sql/colexec/external ./pkg/tests/issues with repository CGo include/library paths
  • Remote [email protected]: make -j4 cgo and focused Kafka reader plus SQL regression tests

After planner pruning, only projected column names are available to the reader. The fix validates the object's total key count and all projected data keys; validating names of unprojected keys would require a larger planner-to-reader contract change.

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

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-xupeng · done

Commit: aafb335ad40a84adcecf5e6c274cbfecfc7067e6

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-xupeng · review

Commit: aafb335ad40a84adcecf5e6c274cbfecfc7067e6

Assessment: approve

Reviewed the complete four-file delta, issue #29856, planner inputs, materialization and error/progress lifecycle. The fix correctly separates declared JSON object width from projected fields while preserving metadata synthesis and existing conversion paths. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a15209-2c6d-71e2-b8f3-aa17387fa283 · slot 2 · generation 0

Validation:

  • Verified clean assigned HEAD/merge-base, supplied patch consistency and git diff --check.

  • Independently reconciled exact-head CI run 39534708663: the external-reader package passed unfiltered race testing; the issues package completed successfully, including TestIssue29856KafkaJSONProjection (0.96s).

  • Normal coverage producer job 119009005594 completed with exit 0, 83222 pass events and no failed events. SCA job 119008966689 completed vet/molint and golangci-lint successfully.

  • Reviewed strict/non-strict projections, short-object rejection, CSV controls, existing malformed-message/progress tests and fixture cleanup.

  • Evidence retained in attempt-1/review-evidence.json and review-notes.json. Audit receipt checks/1792554519332110700-4.json matches the command, clean source fingerprint, exit 0 and retained review-audit logs.

Limitations:

  • No local Go tests, native builds or benchmarks were repeated; exact-head CI evidence was reused.

  • SQL regression uses a real frontend/planner/reader with kfake, not a live Apache Kafka deployment.

  • Validation checks total object key count and projected key names; unprojected key names/types remain outside the reader’s current contract, as disclosed in the PR.

@mergify mergify Bot added the queued label Oct 21, 2026
@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 03:51 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-21 08:09 UTC · at 548d4993f458b48445b182fe2782ceb008850a7f

This pull request spent 4 hours 17 minutes 58 seconds in the queue, with no time running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, 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

Requeued — the merge queue status continues in this comment ↓.

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

Deep review of exact head aafb335 against base/merge-base 63a964a. Read all four changed files, linked #29856, all historical reviews/comments and the empty inline/thread collections. No blocking findings.

Verified the declared-width -> projected fields -> synthetic metadata closure from planner/compile into Kafka object parsing and materialization. The parser validates full declared key cardinality and projected key names before bypassing the invalid slice-length check; ordinary JSONL/CSV paths and per-column conversions remain intact. Short/malformed messages fail before clean-drain progress publication, and the existing Close/Reset/statement-terminal ownership still discards failed progress. Test fixtures use the existing shared embedded cluster with bounded fake-Kafka producer/reader operations and lexical cleanup.

The documented limitation that unprojected key names/types are unavailable after pruning is accepted for this focused fix; this is not an assertion of full-schema validation.

Independently verified and reused exact-head CI 39534708663: raw UT 119008966686 and checkpoint show the external-reader package in the unfiltered race run and successful issues-package batches; TestIssue29856KafkaJSONProjection is explicitly PASS (0.96s). Normal coverage producer 119009005594 exited 0 with 83,222 pass events and no failures, and raw SCA 119008966689 completed vet/molint and golangci-lint with 0 issues. Local gofmt/diff --check are clean. No duplicate local Go/native rebuild was run; SQL validation uses real MO frontend/planner/reader with kfake, not a live Apache Kafka deployment.

@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 09:29 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-21 14:22 UTC · at 6470f608f2372df947c3868f51fff41cee1ca6ba

This pull request spent 4 hours 53 minutes 9 seconds in the queue, with no time running CI.

Reason

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

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

  • Requeue this pull request

@mergify mergify Bot removed the dequeued label Oct 21, 2026

This branch was previously deployed

1 inactive deployment
ci — 6470f608 Deployed Oct 21, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Kafka JSON projection rejects valid rows in strict mode and returns NULL message offsets in non-strict mode

4 participants