Skip to content

expr: Convert CastArrayToString to the sqlfunc macro - #39091

Closed
antiguru wants to merge 1 commit into
sqlfunc-convert-timefrom
sqlfunc-convert-array
Closed

antiguru wants to merge 1 commit into
sqlfunc-convert-timefrom
sqlfunc-convert-array

Conversation

@antiguru

@antiguru antiguru commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Converts CastArrayToString to #[sqlfunc]. It was a hand-written LazyUnaryFunc because it allocates its result, which the arena passed to EagerUnaryFunc::call now covers. Its NULL check moves into the input type: ExcludeNull<Datum<'a>> keeps propagates_nulls true and returns NULL for a NULL input, as before.

The registry reports only sqlfunc_signature moving, on the one record.

Based on #39090.

🤖 Generated with Claude Code

@antiguru
antiguru requested a review from a team as a code owner September 23, 2026 21:10
@antiguru
antiguru added this pull request to stack #38942 September 24, 2026 08:52
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from f9edeb7 to f65b9ea Compare September 24, 2026 10:14
@antiguru
antiguru force-pushed the sqlfunc-convert-array branch from 03ab635 to aee4830 Compare September 24, 2026 10:14
@antiguru
antiguru requested a review from petrosagg September 24, 2026 11:18
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from f65b9ea to 85c03fd Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-array branch from aee4830 to 1b2596d Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from 85c03fd to a5999db Compare September 25, 2026 16:00
@antiguru
antiguru force-pushed the sqlfunc-convert-array branch from 1b2596d to 735e42b Compare September 25, 2026 16:00
@antiguru
antiguru removed the request for review from petrosagg October 13, 2026 15:56
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from a5999db to a95413f Compare October 14, 2026 09:11
@antiguru
antiguru force-pushed the sqlfunc-convert-array branch from 735e42b to 940e58a Compare October 14, 2026 09:11
@antiguru
antiguru requested a review from mgree October 14, 2026 10:22
The impl was hand-written because it allocates its result, which the eager
trait now covers: a `String` output is pushed into the arena by
`OutputDatumType::into_result`, exactly as the body did by hand.

The body also checked NULL itself, and under the macro that check has to come
from the input type. The input is `ExcludeNull<Datum<'a>>`, because
`stringify_datum` takes a raw `Datum` and a bare `Datum` accepts NULL.
`ExcludeNull` reports `nullable() == false`, so the derived `propagates_nulls`
is true, matching the impl's declaration, and its `try_from_result` turns
`Datum::Null` into `Err(Ok(Datum::Null))`, which the evaluation layer returns
as `Ok(Datum::Null)`. That is the manual check, so the manual check is gone.
`introduces_nulls` derives false from the non-`Option` `String` inside the
`Result`, matching the declaration.

Per-override accounting: `eval` becomes the function body minus the NULL check.
`output_sql_type` returned `String.nullable(input_type.nullable)`, which is
what the derived `String` output plus the unary tail gives for a non-nullable
input, so no output modifier is needed. `preserves_uniqueness = true` carries
over. `propagates_nulls` and `introduces_nulls` are derived as above.
`could_error` was not overridden and inherited `LazyUnaryFunc`'s conservative
`true`, which the fallible `Result` output derives. `is_monotone` and
`is_eliminable_cast` returned the trait defaults and are dropped, as is
`inverse`, whose `TODO?` about moving `typeconv` into `expr` now sits on the
function.

`Display` wrote a fixed string, so `sqlname` reproduces it.

The registry reports only `sqlfunc_signature` moving, on the one record.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antiguru
antiguru force-pushed the sqlfunc-convert-array branch from 940e58a to f8baffe Compare October 14, 2026 15:18
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from a95413f to a2e032f Compare October 14, 2026 15:18
@antiguru
antiguru removed this pull request from stack #38942 October 14, 2026 15:45
@antiguru

Copy link
Copy Markdown
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 antiguru closed this Oct 14, 2026
@antiguru
antiguru deleted the sqlfunc-convert-array branch October 14, 2026 19:52
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