feat: support nullable scalar Function declarations (#5030)

Function declarations currently reject nullable scalar returns. Accept
`Optional[T]`, `T | None`, and explicit nullable Arrow fields,
preserving `nullable: true` in registration signatures, JSON round
trips, and remote `add_columns` requests.

The Rust planner accepts nullable scalar outputs, and binding readback
recognizes the server-owned assignment marker for a single nullable
scalar result. Clients do not allocate that marker. Non-nullable whole
results, whole structs, and Blob v2 retain their existing assignment
restrictions.

Validated with 127 Python tests, 30 documentation tests (1 skipped), and
seven focused Rust tests covering planning, binding readback, rejection
boundaries, and the remote request body. The final condition-collapse
change addresses strict Clippy; its delta check and CI are pending.
Python tests use a source overlay on a retained native extension, and
Rust remote coverage uses HTTP mocks.

Server support and end-to-end validation remain separate. This PR does
not claim that server publication distinguishes computed NULL values
from pending rows.
This commit is contained in:
Xuanwo
2026-11-14 20:59:20 +08:00
committed by GitHub
parent 005b33fa8b
commit e5a5b67212
8 changed files with 517 additions and 50 deletions
+6 -5
View File
@@ -295,11 +295,12 @@ extract_frame_version = db.create_function_async(extract_frame).wait(
```
</CodeGroup>
An empty byte string is a filled result. A scalar output cannot be nullable,
because a physical NULL marks an unfilled computed row. To return a nullable
blob as a value, use a named-struct output schema with a nullable blob field;
the struct itself records whether the result has been filled. Read a nested
blob with `table.fetch_blobs("payload.image", hits)`.
An empty byte string is a filled result. A top-level Blob v2 output cannot be
nullable; to return a nullable blob as a value, use a named-struct output
schema with a nullable blob field. The struct itself records whether the
result has been filled. A nullable non-Blob scalar output is declared with
`Optional[T]` or `T | None`; see [Functions](/management/function#define).
Read a nested blob with `table.fetch_blobs("payload.image", hits)`.
A list or large-list output may also contain Blob v2 elements; inputs and
fixed-size lists do not support this layout. List-nested values are queryable