Skip to content

expr: Convert time.rs to the sqlfunc macro - #39090

Closed
antiguru wants to merge 1 commit into
sqlfunc-convert-datefrom
sqlfunc-convert-time
Closed

antiguru wants to merge 1 commit into
sqlfunc-convert-datefrom
sqlfunc-convert-time

Conversation

@antiguru

@antiguru antiguru commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Converts ExtractTime, DatePartTime and TimezoneTime to #[sqlfunc]. All three read their payload, so they take &self, and they need no output modifier. Their Display impls print the payload, so they stay hand-written under skip_display. The method generated for TimezoneTime has the same name as the module's free timezone_time, so the body calls self::timezone_time explicitly.

The registry reports only sqlfunc_signature moving, on all five records.

Based on #39089.

🤖 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-date branch from 39c186f to f2e201e Compare September 24, 2026 10:14
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from f9edeb7 to f65b9ea 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-date branch from f2e201e to d45e6db Compare September 24, 2026 14:29
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch 2 times, most recently from 85c03fd to a5999db Compare September 25, 2026 16:00
@antiguru
antiguru force-pushed the sqlfunc-convert-date branch from d45e6db to 893ab72 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 requested a review from mgree October 14, 2026 10:22
`ExtractTime`, `DatePartTime` and `TimezoneTime` all read their payload in
`call`, so each takes a `&self` receiver.

None of them needs an output modifier. Each hand-written `output_sql_type`
returned the derived output column type with nullability taken from the input,
and the macro's unary tail is `output.nullable(nullable || (propagates_nulls &&
input_type.nullable))`, which for the non-nullable `NaiveTime` input and a
non-nullable output collapses to exactly that.

Per-override accounting, for all three: `call` becomes the function body, and
`output_sql_type` becomes the derived default. Nothing else was overridden, so
`could_error` stays derived, true for the two `Result` outputs and false for
`TimezoneTime`, and `propagates_nulls` derives true from the non-nullable
input.

All three `Display` impls format the payload, so they stay hand-written under
`skip_display = true`.

`TimezoneTime`'s function name collides with the module's free `timezone_time`.
The generated method is inherent, so the two coexist, and the body spells the
call `self::timezone_time` to say which one it reaches.

The registry reports only `sqlfunc_signature` moving, on all five records.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@antiguru
antiguru force-pushed the sqlfunc-convert-time branch from a95413f to a2e032f Compare October 14, 2026 15:18
@antiguru
antiguru force-pushed the sqlfunc-convert-date branch from 27ae985 to add3025 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-time 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