Skip to content

GH-50435: [Ruby] Add ArrowFormat::Time{32,64}.new(unit, values)#50443

Merged
kou merged 1 commit into
apache:mainfrom
kou:ruby-time-array-new
Jul 9, 2026
Merged

GH-50435: [Ruby] Add ArrowFormat::Time{32,64}.new(unit, values)#50443
kou merged 1 commit into
apache:mainfrom
kou:ruby-time-array-new

Conversation

@kou

@kou kou commented Jul 9, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Building a time{32,64} Arrow array from Ruby objects is convenient.

What changes are included in this PR?

Accept ArrowFormat::Time{32,64}.new(unit, values).

Are these changes tested?

Yes.

Are there any user-facing changes?

Yes.

Copilot AI review requested due to automatic review settings July 9, 2026 07:46
@kou kou changed the title GH-50435: [Ruby] Add ArrowFormat::Time{32,64}.new(values) GH-50435: [Ruby] Add ArrowFormat::Time{32,64}.new(unit, values) Jul 9, 2026
@github-actions github-actions Bot added the awaiting committer review Awaiting committer review label Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

⚠️ GitHub issue #50435 has been automatically assigned in GitHub to PR creator.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Ruby red-arrow-format API to make it easier to construct Arrow Time32/Time64 arrays directly from Ruby values by allowing the unit to be passed as a symbol and by enabling packing for these temporal types.

Changes:

  • Add pack_template implementations for Time32Type and Time64Type so PrimitiveArray can pack Ruby values into the values buffer.
  • Extend Time32Array/Time64Array initialization to accept a unit Symbol (e.g., :second, :microsecond) and coerce it into the corresponding Time{32,64}Type.
  • Add new unit tests covering initialization and equality/slicing behavior for Time32Array and Time64Array.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
ruby/red-arrow-format/lib/arrow-format/array.rb Adds type coercion hook so Time32Array/Time64Array can accept a unit symbol.
ruby/red-arrow-format/lib/arrow-format/type.rb Adds packing templates for Time32Type/Time64Type to support building arrays from Ruby values.
ruby/red-arrow-format/test/test-time32-array.rb New tests for building and comparing Time32Array from Ruby values (including nils and slicing).
ruby/red-arrow-format/test/test-time64-array.rb New tests for building and comparing Time64Array from Ruby values (including nils and slicing).

Comment on lines +469 to +477
def ensure_type(type)
case type
when Symbol
unit = type
Time32Type.new(unit)
else
type
end
end
Comment on lines +482 to +490
def ensure_type(type)
case type
when Symbol
unit = type
Time64Type.new(unit)
else
type
end
end
Copilot AI review requested due to automatic review settings July 9, 2026 08:13
@kou kou force-pushed the ruby-time-array-new branch from 05f67ed to 5b39af1 Compare July 9, 2026 08:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines 193 to 197
else
type = args.shift
type = self.class.type_class.try_convert(type) || type
expected_n_args = "2 or 4"
end
Copilot AI review requested due to automatic review settings July 9, 2026 08:51
@kou kou force-pushed the ruby-time-array-new branch from 5b39af1 to c7ae3ff Compare July 9, 2026 08:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines 194 to +197
type = args.shift
unless type.is_a?(Type)
type = self.class.type_class.try_convert(type) || type
end
@kou

kou commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

+1

@kou kou merged commit 6166ef5 into apache:main Jul 9, 2026
33 checks passed
@kou kou removed the awaiting committer review Awaiting committer review label Jul 9, 2026
@kou kou deleted the ruby-time-array-new branch July 9, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants