Repository navigation
fix(plan): preserve nullable metadata for NULL-producing strict functions - #26902
Conversation
…trict-function-nullability
…trict-function-nullability
XuPeng-SH
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 1 hour 1 minute 21 seconds in the queue, including 1 hour 49 seconds running CI. Required conditions to merge
|
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]>
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]>
What type of PR is this?
Which issue(s) this PR fixes:
issue #26830
What this PR does / why we need it:
Covered behavior
NOT NULL:/,DIV,MOD,JSON_EXTRACT,JSON_EXTRACT_STRING,JSON_EXTRACT_FLOAT64,REGEXP_SUBSTR,INET6_ATON,ELT,UNHEX, andMAKEDATE.ROW_NUMBER,RANK,DENSE_RANK,PERCENT_RANK,NTILE, andCUME_DIST.CASE,COALESCE,ISNULL, and value-window functions.Non-goals
Validation
JSON_EXTRACT_STRINGandJSON_EXTRACT_FLOAT64were inferredNOT NULLfrom non-NULL inputs even though missing paths and target-type mismatches produce SQLNULL.a66a7c6535474b35165c78405cebeb9614fcf9b1— all three JSON extractor IDs share the NULL-synthesizing contract.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.DeduceNotNullableand registry-contract tests throughmo-cgo-test: PASS../pkg/sql/plan/functiontests throughmo-cgo-test: PASS.make build: PASS.test/distributed/cases/function/func_strict_nullability.sql: PASS locally against an isolated current-sourcemo-service. View and CTAS metadata reportYESfor both typed extractors' missing-path and type-mismatch cases; every corresponding runtimeIS NULLcheck returns1; preserved ordinary/window controls also match the checked-in result.PASS semantic=PASSon exact local heada66a7c6535474b35165c78405cebeb9614fcf9b1, diff hash0faf7016998defe08ddb92a0e1b47830e1abe705d2c89af1e3be5b643de15656.mo-self-review: PASS with no open blockers; no concurrency/resource/race-stress dimension applies.git diff --check: PASS.QA
function.DeduceNotNullable->plan.Expr.Typ.NotNullable-> view/CTAS metadata and execution.NOT NULLcontrols.a66a7c6535474b35165c78405cebeb9614fcf9b1.