Skip to content

expr-derive-impl: support stateful unary/binary in sqlfunc macro#36697

Draft
antiguru wants to merge 3 commits into
MaterializeInc:mainfrom
antiguru:sqlfunc-self-arena
Draft

expr-derive-impl: support stateful unary/binary in sqlfunc macro#36697
antiguru wants to merge 3 commits into
MaterializeInc:mainfrom
antiguru:sqlfunc-self-arena

Conversation

@antiguru
Copy link
Copy Markdown
Member

Extends #[sqlfunc(...)] to accept stateful structs and arena access for unary and binary functions. Bumps EagerUnaryFunc::call to take &'a self and &'a RowArena, mirroring the variadic shape. Adds skip_display = true modifier for structs needing custom Display.

Migrates 19 hand-written LazyUnaryFunc impls (compound-type casts, regex match/split, record_get, etc.) in src/expr/src/scalar/func/impls/* to the macro form.

Remaining hand-written impls: the 6 short-circuit variadics (And, Or, Coalesce, ErrorIfNull, Greatest, Least) plus CaseLiteral, which require true lazy semantics over MirScalarExpr.

Prep work for collapsing per-sqlfunc monomorphizations into vtable dispatch (prompt).

antiguru and others added 3 commits May 22, 2026 17:07
Extend `#[sqlfunc(...)]` to accept stateful structs and arena access for
unary and binary functions. Bumps `EagerUnaryFunc::call` to take
`&'a self` and `&'a RowArena`, mirroring the variadic shape. Adds
`skip_display = true` modifier for structs with non-trivial `Display`.

Migrates 19 hand-written `LazyUnaryFunc` impls in `scalar/func/impls/*`
to use the macro form. Remaining hand-written impls are the 6 short-
circuit variadics (And, Or, Coalesce, ErrorIfNull, Greatest, Least)
plus CaseLiteral, which require true lazy semantics.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add `RowArena::make_datum_array` mirroring `make_datum_list`. Switch
`cast_string_to_array` and `cast_array_to_array` to return
`Array<'a>` instead of `Datum<'a>`, removing `try_make_datum +
try_push_array` boilerplate.

Drop the unused `_temp_storage` parameter from `record_get`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`T: Borrow<Datum<'a>>` only constrains the iter Item type; it does not
verify that the borrowed `Datum`'s variant matches what T's reader
expects. Callers passing T = i32 with `Datum::String` inputs would
satisfy the bound and produce typed handles whose `typed_iter()`
panics. Add doc warning to both helpers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant