Skip to content

Preserve SQL NULL at the Starlark procedure boundary - #30131

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:fix/29151-starlark-sql-null
Oct 14, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
VioletQwQ-0:fix/29151-starlark-sql-null

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

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

Which issue(s) this PR fixes:

issue #29151

What this PR does / why we need it:

Preserve SQL NULL as Starlark None for procedure arguments, mo.getvar(), and cells returned by mo.sql(). Previously nullable arguments failed conversion, while SQL NULL cells became indistinguishable from empty strings. Non-NULL result cells retain their existing string conversion, and outbound None continues to produce SQL NULL.

Add focused conversion/builtin tests and a self-contained SQL regression for nullable numeric/string inputs, INOUT, empty strings and zero values, mixed rows and columns, and outbound NULL. Test both result-cell error paths without publishing partial results, and update an existing result mock for NULL inspection.

Validation (Linux CPU/CGo, unchanged frozen content; evidence imported and verified on Mac):

  • Base: 5c959556431225711a33d1af5fe9a5b6d4060122; head: cd79b0b8db345526f005b40bd366db3e529bd16e; tree: 091bcbb9d3a38750f7a89c0d24c8b0c65fd772d3.
  • Base behavior: real SQL reproduction confirms rejected nullable IN arguments / getvar and NULL cells returned as empty strings.
  • PR-head behavior: CGo-enabled focused tests and complete pkg/frontend passed (exit 0); formatting, vet, configured incremental lint, official service build and native verification passed.
  • BVT: test/distributed/cases/procedure/starlark_null.sql and .result; canonical mo-tester -n -g -o -p normal comparison passed twice on the same instance, 33/33 each, no failed/ignored/abnormal cases. Explicit database/procedure catalog counts were zero between and after runs; the owned service was stopped.
  • Validation was run at original cloud commit 8171a59977b67229c2b92e9c8f3c5da236c58dc0; the current commit corrects author/committer identity for CLA with an identical tree and empty source diff.
  • Mac import: archive SHA256, bundle/source/patch/evidence hashes, exact head/tree/diff, clean worktree and git diff --check verified. The machine move did not change relevant validation inputs.

QA required: yes — user-visible SQL/Starlark NULL semantics change. Automation covers real CALL, session variables, mixed result cells and reverse NULL conversion; release/client and deployment compatibility remain external QA work. Non-NULL cell typing and unrelated Starlark types are outside this change. Use the issue reference above to keep QA acceptance separate from merge.

Independent semantic review completed with a fresh gpt-6-astra / medium reviewer: Stage A independently reviewed the original issue, formal contract and frozen source before seeing author evidence; immutable A found no concrete in-scope defects. Stage B then reconciled raw execution, source identity, failure recovery and cleanup evidence and found no mandatory semantic gaps. No code/test corrections were required.

Ready for external review under the requested policy. External CI/CR, CLA confirmation and QA acceptance remain pending; none is claimed as passed. The original cloud commit used an unlinked identity; author/committer metadata has been corrected to the verified contributor with the same code tree, and the CLA service result still requires confirmation.

@CLAassistant

CLAassistant commented Oct 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@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 14, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: cd79b0b8db345526f005b40bd366db3e529bd16e

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: cd79b0b8db345526f005b40bd366db3e529bd16e

Assessment: approve

Reviewed the complete five-file delta and callers. The fix preserves SQL NULL as Starlark None through existing conversion owners, retains non-NULL behavior and error handling, and adds no duplicate state or execution path. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a12d8f-8e48-7622-ad17-b605f08450ce · slot 1 · generation 0

Validation:

  • Traced CALL arguments, session variables, SQL result materialization and outbound conversion; reviewed unit-test controls and the SQL/result regression.

  • Reconciled current-head CI successes for Linux UT, static analysis, build, coverage, proxy BVT and pessimistic multi-CN BVT. Reviewed frontend test selection and procedure BVT routing.

  • Local source reconciliation passed: clean assigned HEAD, matching patch and diff check. Receipt: checks/1791951851385950684-2.json; log: reconcile-evidence.log. Detailed audit retained at /home/xupeng/.local/state/mo-bot/jobs/6d2fea1d8383d39b73bc374c/attempt-1/review-evidence-audit.json.

Limitations:

  • No local runtime tests were rerun. Raw CI logs and author execution artifacts were absent; individual execution counts were not independently verified.

  • Issue #29151's body was absent; behavioral scope follows the supplied PR description.

  • Performance was assessed from source, not benchmarked: one additional in-memory lookup per mo.sql cell, without added I/O, synchronization or asymptotic allocation. Ordinary SQL paths are unchanged.

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

mergify Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-14 04:25 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-14 05:37 UTC · at e588adb249c3571bd41c4dc7edf53cea80938efe

This pull request spent 1 hour 11 minutes 44 seconds in the queue, with no time running CI.

Reason

Pull request #30131 has been merged manually at 959d12d

Hint

You were too fast!

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 959d12d into matrixorigin:main Oct 14, 2026
@mergify mergify Bot removed the queued label Oct 14, 2026
XuPeng-SH pushed a commit that referenced this pull request Oct 15, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue #29155

## What this PR does / why we need it:

Starlark procedures currently copy OUT/INOUT values directly into caller
variables, bypassing declared SQL types. This change preserves each
Starlark scalar as a SQL literal and uses the existing stored-procedure
assignment cast, including declared widths. All emitted outputs are
converted before the output flush updates caller variables, so a
rejected output publishes no outputs. Conversion errors also reach the
existing transaction finalizer.

The SQL value extractor now copies all six supported array
representations before releasing their evaluation vector. This gives
staged vector outputs owned storage and also fixes the same lifetime
boundary for ordinary SET and SQL procedures.

Large integer literals retain their exact value: UINT64_MAX and 1<<64
can be assigned to DECIMAL(30,0), while values exceeding the declared
precision follow SQL conversion errors. Missing out_ globals and the
unspecified winner of valid aliased outputs retain their existing
behavior; every alias declaration is still validated. Undeclared
mo.setvar conversion is unchanged.

Original feature validation on head `8c758b29` (historical; unchanged
evidence reused where applicable), native Darwin arm64 / Go 1.27.1 /
CGO:

- The original SQL reproduced on clean base
`1b66ff135c64ef1c642a297105bf599cd3173dee`; independent SQL-procedure
controls established the expected type conversions and rejection
behavior before implementation.
- Focused output/atomicity/array-ownership tests passed; the complete
frontend package passed. Vet, incremental lint, gofmt, and diff checks
passed.
- New canonical `procedure/starlark_parameter_types.sql` and `.result`
cover integer widths and signedness, decimal precision, temporal,
binary, vector and string widths, NULL, OUT/INOUT, aliases, rollback and
reuse. Two normal mo-tester comparisons passed 464/464 each on the same
instance, with independent database-cleanup assertions between and after
runs.
- Existing Starlark and SQL-error BVT passed 45/45 and 19/19.
- PR #30131 applies cleanly in an isolated composition checkout; its
native tests and real SQL composition passed. That historical
composition used the then-separate PR #30131. It has since merged and
its NULL support is included in the current integrated base; the
historical execution evidence above remains bound to its original
revision.

QA required: yes. This changes production stored-procedure result and
rejection behavior. Automated developer validation covers the native SQL
terminal and failure recovery; deployed QA should confirm the target
distributed deployment, including both CNs. Deployed QA and remote CI
are separate from the local validation above.

Independent semantic preflight completed against final head
`8c758b291ef7da349e81a6f2834357a7d2e1bdd7`: a fresh Astra source-only
pass, raw-evidence reconciliation, and re-review of the strengthened
rollback prerequisite found no remaining semantic blockers. The INSERT
error guard ensures the rollback assertion observes a successful INSERT
before the expected output cast rejection.

Remote CI has not been claimed as passing. On previous head
`bb23bb4fb29c549af3ceea4275c0e3aac103e812`, Ubuntu UT and Linux arm64
SCA failed during checkout with Git fetch/TLS network errors before
running the product checks. Final-head CI and deployed QA remain
separate external validation.

## Historical two-type P2 repair and validation (`949e8f5`)

Non-nil VECF32/VECF64 outputs now re-enter the Starlark input converter
through the existing SQL vector string representation. Typed-nil vector
inputs retain the existing rejection. The canonical case repeats CALL
twice for each vector type without resetting the caller variable; all
four equality checks return 1.

The patch's focused regression and complete frontend package passed with
native CGo, as did incremental vet/lint, gofmt and diff checks. Two
normal mo-tester comparisons of the complete
`procedure/starlark_parameter_types.sql` case passed **476/476 each**,
with **0 failed, ignored or abnormal statements**. Both rounds used the
same verified production content and independent empty-fixture cleanup.
Client and service termination and port release were verified. Earlier
staging-path/tool attempts are not counted as product validation.

Actual service SHA256:
`dd2d84346ce719ccc4bea644ff9c9b641991295d5770bc7beffea3022caabd2c`;
native-library SHA256:
`8af9f7ac6c9d3bc2df019e3288ab0c5e6206c203a636d3d52a9529ab215874c2`.
Local runtime was Darwin arm64 / Go 1.27.1 / CGo. Base snapshot remains
`1b66ff135c64ef1c642a297105bf599cd3173dee`; this incremental repair did
not sync merely because main advanced.

This closes the implementation/evidence requirements of XuPeng-SH's
vector INOUT reuse finding, not the formal reviewer decision. New-head
CI and deployed two-CN QA remain separate; that historical dependency is
now integrated through merged #30131. QA required: yes; issue #29155
stays open pending its full acceptance gates.

## Current six-type repair and exact-head verification (`99bf4e6f`)

Current head `99bf4e6f768e06ccad20b29d0e925524bafa32ee` extends non-nil
vector input conversion and repeated-call coverage to VECF32, VECF64,
VECBF16, VECF16, VECINT8 and VECUINT8. Typed-nil slices retain
rejection. The same caller value is used across three CALLs without
resetting it; dimension-error recovery, scalar/NULL controls and array
ownership remain covered. Initial NULL-to-vector reuse is now supported
by the merged #30131 capability in the integrated base.

Exact-head Actions run
[38526355765](https://github.com/matrixorigin/matrixone/actions/runs/38526355765)
supplies **9 relevant roots / 155 terminal PASS records**, including all
six vector-reuse and all six typed-nil subtests. The complete frontend
package reports terminal PASS. The COMPOSE job explicitly selected the
committed `procedure/starlark_parameter_types.sql` case and reports
**647/647 success, zero failed/ignored/abnormal**. These are reconciled
CI results, not a fresh local execution or an assertion that the
complete workflow is green.

Local native build/provenance verification passed. The local focused
attempt stopped during compilation at its disk-budget safety gate; it
ran no tests and remains **BLOCKED_ENVIRONMENT**. No local test PASS or
new two-round647 cleanup proof is claimed.

The vector-reuse findings have current source and executable evidence
for re-review. Whole-PR CI remains failed in the independent
`cmd/mo-service.TestResolveGossipSeedAddresses` case; its cause is not
declared flaky/upstream and no rerun is implied. Current reviewer
decisions, deployed two-CN QA and issue closure remain separate.

<!-- maintenance-six-vector-99bf4e6-ci155-bvt647:v1 -->

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@VioletQwQ-0
VioletQwQ-0 deleted the fix/29151-starlark-sql-null branch October 19, 2026 18:35

This branch was successfully deployed

No deployments
ci — e588adb2 Deployed Oct 14, 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/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants