Skip to content

feat: support casting Time32 to Int64#8971

Merged
alamb merged 2 commits intoapache:mainfrom
tshauck:support-time32-to-bigint
Dec 11, 2025
Merged

feat: support casting Time32 to Int64#8971
alamb merged 2 commits intoapache:mainfrom
tshauck:support-time32-to-bigint

Conversation

@tshauck
Copy link
Copy Markdown
Contributor

@tshauck tshauck commented Dec 8, 2025

Which issue does this PR close?

While this issue was raised on the datafusion side, I think this is where the underlying issue exists, i.e., that arrow cannot do the cast directly.

Rationale for this change

It should be possible to directly go from a time32 to an int64, but currently it is not.

What changes are included in this PR?

  1. Add match arms for needed cases.
  2. Add test that mimics cast issue described in datafusion issue.

Are these changes tested?

Yes, adds test to mimic the case described in the datafusion issue.

Are there any user-facing changes?

No

@github-actions github-actions bot added the arrow Changes to the arrow crate label Dec 8, 2025
Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thanks @tshauck -- this is great. The only thing I think is missing is updating can_cast_types to communicate this cast is supported.

pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {

Thank you 🙏

let to_type = DataType::Int64;
let cast_options = CastOptions::default();

let result = cast_with_options(&array, &to_type, &cast_options);
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.

Can we please also add a test that verifies that can_cast_types supports the cast too, similar to

https://github.com/apache/arrow-rs/blob/7e637a7559837b5a0171b23469e9652f2f83364b/arrow-cast/src/cast/mod.rs#L2882-L2881

Something like this maybe:

        assert!(can_cast_types(array.data_type(), &to_type);

Copy link
Copy Markdown
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @tshauck

@alamb alamb changed the title feat: support time32 to int64 feat: support casting Time32 to Int64 Dec 10, 2025
@alamb alamb merged commit 2d89500 into apache:main Dec 11, 2025
27 checks passed
@tshauck tshauck deleted the support-time32-to-bigint branch December 11, 2025 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to cast Time32 to bigint type

2 participants