Skip to content

fix(arrow/scalar): apply timestamp zones when casting to dates - #1110

Open
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/scalar-timestamp-date-cast
Open

fix(arrow/scalar): apply timestamp zones when casting to dates#1110
fallintoplace wants to merge 2 commits into
apache:mainfrom
fallintoplace:fix/scalar-timestamp-date-cast

Conversation

@fallintoplace

@fallintoplace fallintoplace commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Timestamp-to-Date32 and timestamp-to-Date64 casts use integer arithmetic that truncates negative values and ignores the timestamp timezone.

What changes are included in this PR?

Convert timestamps through the timestamp type's time semantics and reuse the date normalization used by the compute cast path. Add regression coverage around the Unix epoch and a named timezone.

Are these changes tested?

  • go test ./arrow/scalar

Are there any user-facing changes?

No API changes. This corrects the reported behavior while preserving the existing ownership and compatibility contracts.

@fallintoplace fallintoplace changed the title fix(arrow/scalar): preserve timestamp date semantics fix(arrow/scalar): honor timezones when casting timestamps to dates Aug 5, 2026
@fallintoplace fallintoplace changed the title fix(arrow/scalar): honor timezones when casting timestamps to dates fix(arrow/scalar): apply timestamp zones when casting to dates Aug 6, 2026
Comment thread arrow/scalar/temporal.go Outdated
millis := arrow.ConvertTimestampValue(s.Unit(), arrow.Millisecond, int64(s.Value))
return NewDate32Scalar(arrow.Date32(millis / int64(millisecondsInDay))), nil
timestampType := s.DataType().(*arrow.TimestampType)
toTime, err := timestampType.GetToTimeFunc()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the toTime func should already be handling the timestamp offset by using .In, so we shouldn't need to separately add the offset like you're doing

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.

2 participants