Repository navigation
Conversation
antiguru
added this pull request to stack #38942
September 24, 2026 08:52
antiguru
force-pushed
the
sqlfunc-convert-string
branch
from
September 24, 2026 10:14
72b8c84 to
e1ac970
Compare
antiguru
force-pushed
the
sqlfunc-convert-timestamp
branch
from
September 24, 2026 10:14
4ec5632 to
9aebe53
Compare
antiguru
force-pushed
the
sqlfunc-convert-timestamp
branch
from
September 24, 2026 14:29
9aebe53 to
ab55f6f
Compare
antiguru
force-pushed
the
sqlfunc-convert-string
branch
from
September 24, 2026 14:29
e1ac970 to
2b18b50
Compare
antiguru
force-pushed
the
sqlfunc-convert-timestamp
branch
from
September 25, 2026 16:00
ab55f6f to
ba19b21
Compare
antiguru
force-pushed
the
sqlfunc-convert-string
branch
from
September 25, 2026 16:00
2b18b50 to
357a56a
Compare
antiguru
force-pushed
the
sqlfunc-convert-timestamp
branch
from
October 14, 2026 09:11
ba19b21 to
f2987f6
Compare
antiguru
force-pushed
the
sqlfunc-convert-string
branch
from
October 14, 2026 09:11
357a56a to
a4a16bb
Compare
Eleven implementations in `src/expr/src/scalar/func/impls/string.rs` move under `#[sqlfunc]`. The four `impl<E: Eval> LazyUnaryFunc` blocks interleaved among them are generic over a sub-expression type and are untouched. `CastStringToNumeric`, `CastStringToTimestamp` and `CastStringToTimestampTz` read their payload in both `call` and `output_sql_type`, so each takes a `&self` receiver and an `output_type_expr` that builds the scale or precision out of that payload. The expression sets nullability from the input, and the macro's unary tail adds only `propagates_nulls && input_type.nullable`, which the non-nullable `&str` input makes the same term. `introduces_nulls` derives false from the non-`Option` outputs. Their `Display` wrote a fixed string, so `sqlname` reproduces it, and `inverse` carries over as a modifier. `CastStringToChar` and `CastStringToVarChar` need the same shape of `output_type_expr`, plus `could_error = self.fail_on_len && self.length.is_some()`, which a `Result` output would otherwise derive as an unconditional true. `CastStringToVarChar` also keeps `preserves_uniqueness` and `is_eliminable_cast` as expressions over `self.length`. `CastStringToChar`'s `is_eliminable_cast` returned the trait default, so the override goes and its reason moves onto the function. Both format their payload, so they keep their `Display` impls under `skip_display = true`. `IsLikeMatch` and `IsRegexpMatch` need no output modifier: their `output_sql_type` returned `Bool.nullable(input.nullable)`, which is what a `bool` output plus the tail gives. Both read their payload in `call` and format it in `Display`, so they take a `&self` receiver and `skip_display = true`. `CastStringToInt2Vector`, `RegexpMatch` and `RegexpSplitToArray` were hand-written `LazyUnaryFunc` implementations because they allocate into a `RowArena` and check NULL in the body. `EagerUnaryFunc::call` supplies the arena, and the NULL check moves into the input type. The first two take `&'a str`, which is already non-nullable. `RegexpMatch` takes `ExcludeNull<Datum<'a>>`, because `regexp_match_static` wants a raw `Datum` and a bare `Datum` accepts NULL; `ExcludeNull` reports `nullable() == false`, so the derived `propagates_nulls` is true, matching the declaration, and its `try_from_result` turns `Datum::Null` into `Err(Ok(Datum::Null))`, which the evaluation layer returns as `Ok(Datum::Null)`. `CastStringToInt2Vector` returns `Int2Vector<'a>`, whose column type the macro derives, so it needs no output modifier, and it reads no payload, so the macro generates its unit struct. `RegexpMatch` and `RegexpSplitToArray` return a `Datum`, whose column type is not statically known, so each carries an `output_type_expr`. `RegexpSplitToArray` returns NULL only for a NULL input, so it declares `introduces_nulls = false` over the `Datum` default. `RegexpMatch` returns NULL when the pattern does not match, which is what the `Datum` default says. `RegexpReplace` is the one `EagerBinaryFunc`. It reads `regex` and `limit` in `call`, so it takes a `&self` receiver, and its `output_sql_type` spelled out the macro's own binary tail minus the non-nullable-position term, which the non-nullable `&str` inputs make redundant, so it needs no output modifier. Its `Display` reads the pattern, the case sensitivity and the limit, so it keeps its hand-written impl under `skip_display = true`. `doc/developer/sqlfunc.md` named the three convertible `LazyUnaryFunc` implementations that remained. There are none left, so the section now states that the two shapes it describes account for every hand-written implementation under `src/expr/src/scalar/func/`. The registry reports only `sqlfunc_signature` moving, on all sixteen records. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
antiguru
force-pushed
the
sqlfunc-convert-string
branch
from
October 14, 2026 15:18
a4a16bb to
773e421
Compare
antiguru
force-pushed
the
sqlfunc-convert-timestamp
branch
from
October 14, 2026 15:18
f2987f6 to
7937dc3
Compare
antiguru
removed this pull request from stack #38942
October 14, 2026 15:45
Member
Author
|
Folded into #39062, which now carries all twenty file conversions as separate commits, per review feedback to land them as one PR. Posted by Claude Code. |
antiguru
added a commit
that referenced
this pull request
Oct 14, 2026
…ro (#39062) Converts the remaining hand-written scalar functions to `#[sqlfunc]`, one commit per source file or function: the `Cast*ToNumeric` casts (`int16`, `int32`, `int64`, `uint16`, `uint32`, `uint64`, `float32`, `float64`, `jsonb`), `PadChar`, `AdjustNumericScale`, `CastArrayToString`, `CastRangeToString`, and all of `date.rs`, `time.rs`, `map.rs`, `record.rs`, `list.rs`, `timestamp.rs` and `string.rs`. Each commit message accounts for every method the deleted impl overrode. No declared property changes. The registry reports only the macro provenance fields moving. Where a hand-written impl declared a property more conservatively than the body needs, the conversion pins the declared value: `could_error` on `record_get`, and `introduces_nulls`, `could_error` and a nullable output on `map_build_from_record_list`. #39814 corrects both. Supersedes #39079 to #39097, which held one conversion each. Based on #39061. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 (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.
Converts eleven implementations in
string.rsto#[sqlfunc]. The fourimpl<E: Eval> LazyUnaryFuncblocks are generic over the sub-expression type, which the macro doesn't support, so they stay.CastStringToCharandCastStringToVarCharkeep acould_errorthat depends on their payload.CastStringToInt2Vector,RegexpMatchandRegexpSplitToArraywere hand-written lazy impls because they allocate their result and check NULL in the body. The arena passed toEagerUnaryFunc::callcovers the allocation, and the input type covers the NULL check.With these converted,
doc/developer/sqlfunc.mdsays no convertible hand-written implementation remains.The registry reports only
sqlfunc_signaturemoving, on all sixteen records.Based on #39096.
🤖 Generated with Claude Code