Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup cast kernel #2846

Merged
merged 2 commits into from Oct 8, 2022
Merged

Cleanup cast kernel #2846

merged 2 commits into from Oct 8, 2022

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Oct 7, 2022

Which issue does this PR close?

Closes #.

Rationale for this change

The cast kernel predates a lot of the work to introduce safe APIs for interacting with arrays, inspired by the work of arrow2. This updates the cast kernel to make use of these APIs 馃帀

What changes are included in this PR?

Uses PrimitiveArray::reinterpret_cast added by #2785 to reduce use of unsafe

Cleans up some other callsites

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Oct 7, 2022
@@ -1617,33 +1561,6 @@ fn cast_decimal_to_decimal<const BYTE_WIDTH1: usize, const BYTE_WIDTH2: usize>(
}
}

/// Cast an array by changing its array_data type to the desired type
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function isn't sound, as it basically allows arbitrary transmutation of ArrayData 馃槄

Tbh this was the major motivator for this PR, whilst unsoundness in internal APIs is not nearly as bad as in public APIs, it is still something to be avoided.

@tustvold tustvold marked this pull request as draft October 7, 2022 15:18
@tustvold
Copy link
Contributor Author

tustvold commented Oct 7, 2022

Need to revisit how this is handling timestamps

@tustvold tustvold marked this pull request as ready for review October 7, 2022 15:51
@@ -769,11 +769,16 @@ impl<T: ArrowTimestampType> PrimitiveArray<T> {

/// Construct a timestamp array with new timezone
pub fn with_timezone(&self, timezone: String) -> Self {
self.with_timezone_opt(Some(timezone))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went to add this method as was delighted to find #2347 @viirya had already added it. Apparently I reviewed it but have no recollection 馃槅

Added an optional variant of it, as for this specific case it makes it easier to work with

Comment on lines +1326 to +1330
Ok(make_timestamp_array(
&converted,
to_unit.clone(),
to_tz.clone(),
))
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, for this kind of conversion between timezones, I think from_tz must be non empty.

Copy link
Contributor Author

@tustvold tustvold Oct 8, 2022

Choose a reason for hiding this comment

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

Not sure, the values should be UTC. Regardless this was the prior behaviour and there is a ticket already taking this #1936

Copy link
Member

Choose a reason for hiding this comment

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

Okay as it is the prior behavior.

@tustvold tustvold merged commit 9db7518 into apache:master Oct 8, 2022
@tustvold
Copy link
Contributor Author

tustvold commented Oct 8, 2022

As ever, thank you for reviewing my PRs 馃槃

@ursabot
Copy link

ursabot commented Oct 8, 2022

Benchmark runs are scheduled for baseline = 5cf46d4 and contender = 9db7518. 9db7518 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on test-mac-arm] test-mac-arm
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped 鈿狅笍 Benchmarking of arrow-rs-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@viirya
Copy link
Member

viirya commented Oct 8, 2022

@tustvold You're welcome! 鉂わ笍 Thank you for reviewing my PRs too 馃槃

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.

None yet

3 participants