expr-derive-impl: support stateful unary/binary in sqlfunc macro#36697
Draft
antiguru wants to merge 3 commits into
Draft
expr-derive-impl: support stateful unary/binary in sqlfunc macro#36697antiguru wants to merge 3 commits into
antiguru wants to merge 3 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends
#[sqlfunc(...)]to accept stateful structs and arena access for unary and binary functions. BumpsEagerUnaryFunc::callto take&'a selfand&'a RowArena, mirroring the variadic shape. Addsskip_display = truemodifier for structs needing customDisplay.Migrates 19 hand-written
LazyUnaryFuncimpls (compound-type casts, regex match/split, record_get, etc.) insrc/expr/src/scalar/func/impls/*to the macro form.Remaining hand-written impls: the 6 short-circuit variadics (
And,Or,Coalesce,ErrorIfNull,Greatest,Least) plusCaseLiteral, which require true lazy semantics overMirScalarExpr.Prep work for collapsing per-sqlfunc monomorphizations into vtable dispatch (prompt).