Skip to content

expr: Convert list.rs to the sqlfunc macro - #39095

Closed
antiguru wants to merge 1 commit into
sqlfunc-convert-recordfrom
sqlfunc-convert-list
Closed

antiguru wants to merge 1 commit into
sqlfunc-convert-recordfrom
sqlfunc-convert-list

Conversation

@antiguru

@antiguru antiguru commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Converts CastListToString and ListLengthMax to #[sqlfunc]. CastListToString allocates its result, which the arena passed to EagerUnaryFunc::call now covers, and its NULL check moves into its ExcludeNull<Datum<'a>> input. ListLengthMax reads max_layer, so it takes &self, and it needs no output modifier.

doc/developer/sqlfunc.md now names the three hand-written LazyUnaryFunc impls that remain convertible, all in string.rs.

The registry reports only sqlfunc_signature moving, on both records.

Based on #39094.

🤖 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-list branch from e1e3e5f to f9a0c1b Compare September 24, 2026 10:14
@antiguru
antiguru force-pushed the sqlfunc-convert-record branch from 8fb9b56 to ab71954 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-list branch from f9a0c1b to 4ecb9b0 Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-list branch from 4ecb9b0 to e0ab240 Compare September 25, 2026 16:00
@antiguru
antiguru force-pushed the sqlfunc-convert-record branch from 165fb4f to 6eb1536 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-record branch from 6eb1536 to 5663ac0 Compare October 14, 2026 09:11
@antiguru
antiguru force-pushed the sqlfunc-convert-list branch from e0ab240 to 07abebd Compare October 14, 2026 09:11
@antiguru
antiguru requested a review from mgree October 14, 2026 10:22
`CastListToString` 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`. It also checked NULL in the body, which under
the macro has to come from the input type. Its 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 declaration, and its
`try_from_result` turns `Datum::Null` into `Err(Ok(Datum::Null))`, which the
evaluation layer returns as `Ok(Datum::Null)`. `introduces_nulls` derives false
from the `String` inside the `Result`.

Its remaining overrides: `output_sql_type` returned
`String.nullable(input_type.nullable)`, which the derived output plus the unary
tail gives for a non-nullable input, so no output modifier is needed.
`preserves_uniqueness = true` carries over, `could_error` derives true from the
fallible output, matching the `LazyUnaryFunc` default the impl inherited, and
`inverse`, `is_monotone` and `is_eliminable_cast` returned the trait defaults
and are dropped. The `TODO?` on `inverse` now sits on the function. `Display`
wrote a fixed string, so `sqlname` reproduces it.

`ListLengthMax` is an `EagerBinaryFunc` that reads `max_layer` in `call`, so it
takes a `&self` receiver. Its `output_sql_type` spelled out the macro's own
binary tail, minus the non-nullable-position term, which the `Option` output's
`nullable` of true subsumes, so it needs no output modifier. Nothing else was
overridden: `could_error` and `introduces_nulls` derive true from
`Result<Option<i32>, EvalError>`, `propagates_nulls` derives true from the
non-nullable inputs, and `is_infix_op`, `is_monotone`, `is_infinity_monotone`
and `negate` keep the trait defaults. Its `Display` wrote `list_length_max`,
which is the function name, so the generated impl reproduces it without a
`sqlname`. The struct doc loses only its now satisfied TODO.

`doc/developer/sqlfunc.md` counted the convertible hand-written
`LazyUnaryFunc` implementations. Seven of the ten are now converted, so the
paragraph names the three that remain, all in `string.rs`.

The registry reports only `sqlfunc_signature` moving, on both records.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antiguru
antiguru force-pushed the sqlfunc-convert-list branch from 07abebd to cb7b4a1 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-list 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