Skip to content

fix(plan): preserve nullable metadata for NULL-producing strict functions - #26902

Merged
mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-26830-strict-function-nullability
Aug 11, 2026
Merged

mergify[bot] merged 8 commits into
matrixorigin:mainfrom
VioletQwQ-0:codex/issue-26830-strict-function-nullability

Conversation

@VioletQwQ-0

@VioletQwQ-0 VioletQwQ-0 commented Aug 10, 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 #26830

What this PR does / why we need it:

Covered behavior

  • Keeps known NULL-synthesizing functions nullable even when every input expression is NOT NULL: /, DIV, MOD, JSON_EXTRACT, JSON_EXTRACT_STRING, JSON_EXTRACT_FLOAT64, REGEXP_SUBSTR, INET6_ATON, ELT, UNHEX, and MAKEDATE.
  • Keeps the complete JSON extractor family together: both typed siblings remain nullable for missing paths and target-type mismatches.
  • Preserves argument-dependent non-null contracts for ordinary functions such as equality and integer addition.
  • Preserves the complete order-window contract for ROW_NUMBER, RANK, DENSE_RANK, PERCENT_RANK, NTILE, and CUME_DIST.
  • Preserves the existing special handling for CASE, COALESCE, ISNULL, and value-window functions.
  • Adds canonical BVT coverage for view metadata, CTAS metadata, synthesized NULL values, typed JSON missing/type-mismatch cases, ordinary-function controls, and order-window controls.

Non-goals

  • No runtime function values, errors, or NULL-input propagation change.
  • No function overload selection or registry flag reclassification.
  • No change to value-window frame semantics.

Validation

  • Base/reviewed-head behavior: FAIL — JSON_EXTRACT_STRING and JSON_EXTRACT_FLOAT64 were inferred NOT NULL from non-NULL inputs even though missing paths and target-type mismatches produce SQL NULL.
  • PR-head behavior: PASS at a66a7c6535474b35165c78405cebeb9614fcf9b1 — all three JSON extractor IDs share the NULL-synthesizing contract.
  • Unit/integration:
    • GOWORK=off go list -mod=readonly ./pkg/sql/plan/function: PASS.
    • GOWORK=off go build -mod=readonly ./pkg/sql/plan/function: PASS.
    • GOWORK=off go vet -mod=readonly ./pkg/sql/plan/function: PASS.
    • Focused DeduceNotNullable and registry-contract tests through mo-cgo-test: PASS.
    • Full ./pkg/sql/plan/function tests through mo-cgo-test: PASS.
    • make build: PASS.
  • BVT: test/distributed/cases/function/func_strict_nullability.sql: PASS locally against an isolated current-source mo-service. View and CTAS metadata report YES for both typed extractors' missing-path and type-mismatch cases; every corresponding runtime IS NULL check returns 1; preserved ordinary/window controls also match the checked-in result.
  • Semantic preflight: PASS semantic=PASS on exact local head a66a7c6535474b35165c78405cebeb9614fcf9b1, diff hash 0faf7016998defe08ddb92a0e1b47830e1abe705d2c89af1e3be5b643de15656.
  • mo-self-review: PASS with no open blockers; no concurrency/resource/race-stress dimension applies.
  • git diff --check: PASS.

QA

  • QA required: yes.
  • Reason: this changes user-visible SQL nullability metadata and CTAS acceptance.
  • Production entrypoint: SQL binder -> function.DeduceNotNullable -> plan.Expr.Typ.NotNullable -> view/CTAS metadata and execution.
  • Automated terminal coverage: canonical BVT asserts nullable JSON extractor metadata and runtime NULL synthesis while preserving safe NOT NULL controls.
  • Remaining validation: exact-head CI on a66a7c6535474b35165c78405cebeb9614fcf9b1.

@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 exact head a66a7c6 after the requested update.

The previous blocker is closed: JSON_EXTRACT_STRING and JSON_EXTRACT_FLOAT64 now follow JSON_EXTRACT in the NULL-synthesizing exception set, and both unit and BVT coverage exercise missing paths and incompatible target values through view and CTAS metadata as well as runtime results. The wider strict-function nullability rules remain conservative where needed and do not mark an expression NOT NULL when a documented value-dependent NULL path exists.

I found no remaining correctness, compatibility, unhappy-path, or performance blocker. The full function package tests pass locally, all checks are terminal and passing, and diff validation is clean.

@aunjgr aunjgr 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 exact head a66a7c6535474b35165c78405cebeb9614fcf9b1; all checks are terminal and successful.

The complete JSON extractor family now shares the NULL-synthesizing exception, including missing-path and target-type-mismatch behavior. The wider deduction remains conservative for value-window functions and preserves explicit CASE, COALESCE, ISNULL, and ordinary strict-function contracts. Unit and BVT coverage independently exercise metadata and runtime NULLs. I found no remaining correctness or compatibility blocker.

@mergify

mergify Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-11 06:59 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-08-11 08:00 UTC · at e774356045f40a9282d83e18b33401c134f05aae · squash

This pull request spent 1 hour 1 minute 21 seconds in the queue, including 1 hour 49 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI / SCA Test on Linux/arm64
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI / Coverage
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

fengttt added a commit to fengttt/matrixone that referenced this pull request Aug 11, 2026
Address review on matrixorigin#26945: uuid_extract_version/uuid_extract_timestamp
are registered STRICT, but they synthesize SQL NULL from valid non-NULL
UUIDs (non-RFC-4122 variants for both, versions without a time source
such as v4 for uuid_extract_timestamp), so DeduceNotNullable must not
infer NOT NULL results from NOT NULL arguments — the same class as
PR matrixorigin#26902. Add both function ids to the NULL-synthesizing contract in
DeduceNotNullable, with a unit test of the deduction and BVT coverage
of runtime NULLs for v4/non-RFC inputs plus view and CTAS metadata
(desc shows nullable columns; CTAS materializes the NULLs).

Co-Authored-By: Claude Fable 5 <[email protected]>
@mergify
mergify Bot merged commit 494d77c into matrixorigin:main Aug 11, 2026
26 of 27 checks passed
@mergify mergify Bot removed the queued label Aug 11, 2026
fengttt added a commit to fengttt/matrixone that referenced this pull request Aug 11, 2026
Address review on matrixorigin#26945: JudgeIntervalNumOverflow negates num for its
negative-side check, which overflows for math.MinInt64 and lets the
value through to wrapping interval arithmetic — uuid_v7(interval
-9223372036854775808 second) returned a fresh non-NULL UUID with the
current timestamp instead of NULL. Reject math.MinInt64 explicitly
alongside the math.MaxInt64 invalid-interval marker. Adds focused unit
regressions (SECOND and MICROSECOND at MinInt64) and public-SQL BVT
coverage for v1/v6/v7.

Also merges upstream/main (the NULL-synthesizing DeduceNotNullable
contract from matrixorigin#26902 landed there; our UUID extractor ids are folded
into that case list).

Co-Authored-By: Claude Fable 5 <[email protected]>
@aunjgr aunjgr mentioned this pull request Aug 11, 2026
2 of 7 tasks

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/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