Skip to content

feat: bind embedded Sirius MO reads - #29209

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
aunjgr:feature/28966-embedded-read-plan
Sep 29, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
aunjgr:feature/28966-embedded-read-plan

Conversation

@aunjgr

@aunjgr aunjgr commented Sep 21, 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:

Refs #28966. This PR does not close the migration issue.

Review notes

The owner narrowed this migration milestone to MO-reader input on 2026-09-23. Direct-TAE reads and new TAE/lock changes are deferred; #29255 was closed.

The MO-reader-only embedded design v2 supersedes the unmerged direct-TAE draft for this milestone. Sections 3 and 4 define MO-owned input and bindings; sections 6 and 7 retain fail-closed execution and Flight compatibility; section 10 requires all 22 queries on embedded MO-reader input with two streams. Independent technical review of this exact revised design blob has been requested; prior approval of v1 is not being treated as v2 approval.

Focused embedded binding tests, the full pkg/sql/plan/substrait package, go vet, formatting, and diff checks passed locally. Exact-head CI has no failed or pending checks.

What this PR does / why we need it:

Add deterministic, query-local MO read bindings to embedded Sirius Substrait plans. Each binding advertises the exact post-scan schema emitted by its MO producer. Reject invalid sources, binding identities, projections, and hidden-column shapes before native preparation; preserve the existing Flight plan path.

@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 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 exact head 170c4df against main 510e28e.\n\nThe pure binding implementation and focused positive/negative tests are substantially coherent, and the existing Flight extension-table Build path remains isolated.\n\nRequesting changes for the design-first delivery gate: this PR crosses planner/Substrait and the embedded MO/TAE ABI boundary, so it must link the exact reviewed revision of docs/design/sirius-embedded.md and record the implementation alignment/approval before this implementation-boundary PR can be approved. The current body references #28966 but does not identify the design revision or approval record.\n\nPlease add that exact design revision/link and explicitly map the binding ID/source/schema and failure contracts here to the approved design. No production enablement or coverage-percentage issue is being raised.

@aunjgr

aunjgr commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH Addressed the design-first delivery request in the PR body: it now links the exact reviewed design v2 revision (24161f69ba1bfefbd159d120cecc1758d00f98ed), records the approval/delivery-map alignment, and explicitly maps binding identity/source, schema, failure, and deferred-ownership contracts. No code or head SHA changed. Please re-review when convenient.

@aunjgr
aunjgr requested a review from XuPeng-SH September 21, 2026 15:21

@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-reviewed exact head 170c4df against base 510e28e, including all review history and the now-linked embedded-design v2 revision 24161f6. The earlier design-first delivery gap is closed in the PR body without a code/head change. I checked binding identity/order/replay rejection, MO post-scan versus direct-TAE schema semantics, filter/project/fetch ownership, physical column provenance, deterministic wire output, legacy Flight isolation, and the focused negative tests. Exact-head required CI and the owning package tests are green. No blocking correctness issue found; later reader/native PRs still own snapshot/account scoping, lifecycle, bounded buffers, and public GPU evidence as recorded by the design.

@aunjgr
aunjgr requested review from XuPeng-SH and removed request for XuPeng-SH September 22, 2026 08:36
@aunjgr

aunjgr commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH Your review correctly separated the hidden-suffix code fix from the design-first gate. The former is fixed at d6e95dddbd; exact-head CI now has no failed or pending checks.

Please perform and record an independent technical review of the current MO-reader-only docs/design/sirius-embedded.md blob 331110571c8ad735f897940aa8eb694d8170bb5e. The v2 changes narrow input to MO readers, remove new direct-TAE lease/storage ownership from this milestone, and revise cleanup and all-22 acceptance around that route. The owner scope decision is linked in the PR, but I am not treating it or the earlier v1 approval as approval of this revised technical design. If the v2 design has a blocker, please identify the specific invariant or ownership path; otherwise, an explicit design decision on this blob will unblock implementation review.

@aunjgr
aunjgr requested a review from XuPeng-SH September 24, 2026 03:19
@aunjgr

aunjgr commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

@fengttt Thank you for approving #29209 at d6e95dddbd. XuPeng-SH's remaining gate is a traceable independent technical design decision for the revised MO-reader-only design blob 331110571c8ad735f897940aa8eb694d8170bb5e; the earlier v1 approval and owner scope decision do not establish that. If your approval included a review of this exact v2 design, could you please state that explicitly (or identify any design concern)? This would let implementation review proceed without treating an empty approval body as evidence it was not meant to provide.

@aunjgr

aunjgr commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@XuPeng-SH Follow-up on the exact-revision design gate for #29209: the head remains d6e95dd and its MO-reader-only design blob is 331110571c8ad735f897940aa8eb694d8170bb5e. The hidden-column binding defect was fixed at this head and required CI is green. Sirius #22 and MO #29254 have now merged; the native bridge is validated locally against those inputs but remains draft/unpushed until this design gate closes. Could you record an independent technical approval or a concrete remaining design blocker for this v2 blob? I am not treating the earlier v1 approval or an empty implementation approval as that decision.

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

APPROVE — reviewed exact head d6e95dddbd2ad559a3ac08e696030ce9fae27cfb against declared base/merge-base 16d8e5106caaedfe0a7296e4f628683e1b6a92b4. Fresh main checked: 087000434fedf24aaa7f0b2192c34c2aaaf3a9e8. Read all four changed files/hunks and all PR comments/reviews. No subagents. No blocking finding remains in this PR's pure plan-binding scope.

Phase 1: independent technical design decision

I explicitly approve design version 2, blob 331110571c8ad735f897940aa8eb694d8170bb5e, at this head, before the implementation decision below. This closes my earlier exact-revision design-review request; it does not rely on an empty implementation approval or reinterpret the earlier v1 decision.

The MO-reader-only narrowing is technically sound: MO remains the owner of authorization, statement snapshot, relation handles, scan filtering/projection/fetch and result publication. The milestone does not introduce another TAE snapshot/lease/storage authority. Query-local native bindings are preferable to an in-process reimplementation of Flight's resolver or storage admission.

The design compares Flight, eager FFI and Arrow-at-both-boundaries alternatives, separates transport bounds from algorithm state, specifies finite admission/input/output budgets, and requires independent cancellation followed by quiescence before release/reuse. Fatal native failure deliberately fails the MO process closed instead of pretending timeout makes live native memory safe to free. Flight compatibility/recovery remains necessary during coexistence; deleting it in this preparatory PR would be premature. MO-reader performance is compared to controlled Flight+MO, while Flight+TAE remains context rather than a mismatched acceptance baseline. GPU correctness, numeric compatibility, all-22 performance and removal remain explicit downstream cutover gates, not claims delivered here.

Phase 2: implementation and adversarial checks

Closure Verification
Binding identity / native consumer Deterministic read order and IDs, exact binding count, absent/zero/duplicate/swapped IDs, unsupported source and replay rejection. Cross-checked Sirius native plan validator blob 3dc4de8b47d0018b4adde7a464df60f66ab65236: the named-table prefix, canonical positive ID, single occurrence, schema names/types/nullability and backward reference contracts align. This was source inspection, not a linked native run.
Post-scan schema / execution owner Direct projection preserves order, duplicate column occurrences, physical ID/sequence and declared output types; computed/type-mismatched/hidden-column shapes reject. Traced MO's TABLE_SCAN compile path: filter/projection then offset/limit are already applied, so replacing the complete scan avoids applying them twice. Operators above the scan remain in the Substrait tree.
Adjacent controls / legacy path Hidden suffix with empty projection rejects; no-hidden empty projection succeeds. Shared physical scan occurrences reject, while a SINK producer referenced by later SINK_SCAN steps is not a second physical occurrence. Existing Flight Build retains extension-table reads and filter/project/fetch wrappers. These source traces supplement, not masquerade as, freshly executed SQL.
Q1 ownership New maps/slices/protobufs are invocation-local GC-managed plan data. No reader, lease, native handle or asynchronous owner is created here. Failures publish no wire plan and do not mutate candidate state.
Q2 waits / reuse No new blocking I/O, lock, goroutine or cancellation state machine. A failed binding attempt leaves no retained exporter state for a later call. Native wait/teardown obligations remain with the explicitly identified downstream execution owner.
Q3 / cost Metadata work scales with the input plan/schema; existing final wire-size check is retained. This PR adds preparation work, not row/batch buffering or a per-row execution cost. No GPU speedup claim is established by it.

Historical review closure: the hidden-suffix defect is repaired at this exact head with TestEmbeddedMOReadRejectsHiddenSuffixWithoutProjection and its nearest no-hidden control. The earlier missing-link/exact-v2-design decision is closed by the current PR link and the explicit phase-1 approval above. I found no other outstanding actionable request in the fetched review/comment history.

Increment quality and non-blocking simplification

Reviewed separately: implementation +323/-8, tests +241/-0, design +36/-32.

  • The tests use small pure fixtures and assert decoded wire/schema and explicit rejection, including preservation of Flight behavior. No new cluster, sleeps or heavy setup. For this not-yet-connected internal builder, SQL/GPU BVT belongs to the real integration PR; it is not evidence required to pretend this helper already enables offload.
  • There is still avoidable preparation duplication: BuildEmbedded repeats Build's relation/root/version/marshal/size assembly; binding validation and construction recompute embeddedMORead; exporter.read computes physical schema bytes/column mappings that the embedded branch discards. Prefer a small shared serializer and avoiding discarded computations while preserving structural validation. Likewise, preflight occurrence validation and embeddedReadSeen overlap. These are bounded maintainability/cost opportunities, not demonstrated correctness or material runtime regressions; no generic framework/cache is warranted.
  • The revised document removes the direct-TAE route consistently while preserving still-live Flight ownership. The tracking issue body still contains old direct-TAE goals; update its current-scope summary for consistency rather than adding another design document. The owner scope comment and versioned v2 document make the current decision unambiguous.

Evidence and limits

Reused successful exact-head CI run 35837768478, including UT, SCA and existing BVT checks. Downloaded its final-result-files artifact and inspected merged_coverage.out: the new binding code, hidden-column rejection/control, duplicate/replay rejection and projection-error branches have execution hits. This verifies selection, not adequacy by coverage percentage. Author reports focused/full substrait package tests and vet at this head; no fresh local pass is claimed.

git diff --check passed. A local focused test attempt through the prescribed CGo wrapper stopped before test execution: this linked worktree lacks libmo and native-input provenance differs from the primary worktree. I did not bypass provenance or relabel that as a test failure/pass. No product files were changed. Main's later shared-exporter EXTRACT changes were inspected separately; this decision is for the exact PR head, not an untested rebased binary.

Approval is for this plan-binding increment and the identified design revision only, not native bridge delivery, GPU performance acceptance, production cutover or closure of #28966.

@mergify mergify Bot added the queued label Sep 29, 2026
@mergify

mergify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-29 02:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-29 02:31 UTC · at a6659624b384177e8ea96332634160d931915503

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

Reason

Pull request #29209 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

@XuPeng-SH
XuPeng-SH merged commit 466eb8f into matrixorigin:main Sep 29, 2026
24 of 26 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 29, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/api-change kind/documentation Improvements or additions to documentation kind/feature kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants