Skip to content

Trim-safe constructor errors and an Arrow.jl extension for Timestamp - #3

Merged
quinnj merged 1 commit into
mainfrom
jq/trim-safe-errors-arrow
Sep 9, 2026
Merged

quinnj merged 1 commit into
mainfrom
jq/trim-safe-errors-arrow

Conversation

@quinnj

@quinnj quinnj commented Sep 9, 2026

Copy link
Copy Markdown
Member

Two items found while making Timestamp{P} the DATETIME/TIMESTAMP type of MySQL.jl 2.0.

Trim-safe error messages. The Timestamp{P}(y, m, d, …) validation messages interpolated the type parameter and, for the final range check, typemin/typemax Timestamp values. Printing a Timestamp goes through dynamic dispatch, and a string(...) of more than about ten pieces is compiled with Vararg{Any}, so a --trim=safe build that can reach the constructor fails verification (MySQL.jl's trim check had to build its values from a tick count to avoid it). The messages now name the resolution with nameof(P) and the bounds by calendar date, through short string calls; the message text is otherwise unchanged. The trim workload now exercises the three error paths (with non-constant parts, so the calls are not folded into unconditional throws), and unit tests pin the message text.

Arrow.jl extension. Arrow.jl 2.8.1 writes a Timestamp{P} as a nested struct (instant.periods) and reads it back as a named tuple. DurationsArrowExt (weak dependency on Arrow 2.8) maps Timestamp{P} to Arrow's own timestamp logical type at unit P (seconds, milliseconds, microseconds, or nanoseconds; no time zone), tagged with the extension name JuliaLang.Durations.Timestamp so that it reads back as Timestamp{P}; a reader without Durations loaded sees a plain Arrow timestamp column (DateTime in Arrow.jl). Union{Missing, Timestamp{P}} columns work through ArrowTypes' generic handling. Tests round-trip all four resolutions, check the raw column type with convert=false, and check that Arrow.jl's own DateTime mapping is untouched.

Version bumped to 1.2.0 (new extension); drop that hunk if you prefer to bump at release time. On Julia 1.14, where Durations.Timestamp === Dates.Timestamp, the extension's methods apply to the stdlib type; if Arrow.jl later adds its own mapping for Dates.Timestamp, one of the two should yield.

🤖 Generated with Claude Code

- The `Timestamp{P}(y, m, d, …)` validation messages no longer interpolate a `Timestamp`
  or a type: the resolution is named by `nameof(P)` and the range bounds by calendar
  date through short `string` calls. Interpolating a `Timestamp` prints through dynamic
  dispatch, and a `string` of more than about ten pieces is compiled with `Vararg{Any}`;
  a `--trim=safe` build rejected both (found by MySQL.jl's trim check, which had to
  bypass the constructor). The trim workload now exercises the error paths.
- `DurationsArrowExt` (weak dependency on Arrow.jl 2.8): a `Timestamp{P}` column is
  written as Arrow's own timestamp type at unit `P` (no time zone), tagged with the
  extension name `JuliaLang.Durations.Timestamp` so that it reads back as
  `Timestamp{P}`; a reader without Durations sees a plain Arrow timestamp column.
  Before, Arrow.jl wrote the value as a nested struct and read it back as a named tuple.
- Version 1.2.0.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@quinnj
quinnj merged commit 8cf0b31 into main Sep 9, 2026
9 checks passed
@quinnj
quinnj deleted the jq/trim-safe-errors-arrow branch September 9, 2026 16:58
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