Skip to content

fix: report a non-nullable return field for named_struct() and struct() - #75

Merged
adriangb merged 1 commit into
friendlymatthew/pydantic-main-df55from
fork/named-struct-non-nullable
Sep 15, 2026
Merged

adriangb merged 1 commit into
friendlymatthew/pydantic-main-df55from
fork/named-struct-non-nullable

Conversation

@adriangb

Copy link
Copy Markdown
Member

Backport of apache#25306 (issue apache#25305) onto the branch the platform pins.

named_struct() and struct() build their output StructArray with no null buffer but reported a nullable return field, so IS NOT NULL on a constructed struct never folded and a guard on a struct built by a view kept the whole struct alive through projection pushdown. With the return field non-nullable the guard folds to true and the scan is pruned to the fields actually read.

Cherry-picked with -x from the upstream PR commit; the only conflict was the struct.slt tail, resolved by appending the new cases to this branch's version of the file. Needed by the platform change that lets metric_*(value) read only its flat columns while keeping the value IS NOT NULL guard that a CASE-masked struct requires.

Both constructors build their output `StructArray` without a null buffer, so
the struct row they produce is never NULL, but they reported a nullable return
field. Because `ExprSchemable::nullable` reads that field for a scalar
function, the simplifier could not fold `IS NOT NULL` on them to `true`.

A guard such as `WHERE s IS NOT NULL` on a struct built by a view therefore
kept the whole struct expression alive, and projection pushdown could not
prune the scan to the fields that are actually read. With the return field
marked non-nullable the guard folds away and the scan reads only the accessed
column.

(cherry picked from commit a793993)
@adriangb
adriangb merged commit fa47c12 into friendlymatthew/pydantic-main-df55 Sep 15, 2026
65 of 69 checks passed
@adriangb
adriangb deleted the fork/named-struct-non-nullable branch September 15, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant