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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved UX of creating TimestampNanosecondArray with timezones #3088

Merged
merged 3 commits into from
Nov 11, 2022
Merged

Improved UX of creating TimestampNanosecondArray with timezones #3088

merged 3 commits into from
Nov 11, 2022

Conversation

src255
Copy link
Contributor

@src255 src255 commented Nov 11, 2022

Which issue does this PR close?

Closes #3042

What changes are included in this PR?

The with_timezone_utc method is implemented with the timezone "+00:00". Two leading zeros are used for consistency with non-zero offsets. Also, the signature of with_timezone has been changed:

// pub fn with_timezone(&self, timezone: String) -> Self {/* --snip-- */}
pub fn with_timezone(&self, timezone: impl Into<String>) -> Self {/* --snip-- */}

Are there any user-facing changes?

The with_timezone now accepts &str in addition to String. For example,

let arr1: PrimitiveArray<TimestampMillisecondType> =
    TimestampMillisecondArray::from(vec![
        1546214400000,
        -1546214400000,
    ])
//  .with_timezone("+00:00".to_string());
   .with_timezone("+00:00");

let arr2: PrimitiveArray<TimestampMillisecondType> =
    TimestampMillisecondArray::from(vec![
        1546214400000,
        -1546214400000,
    ])
    .with_timezone_utc();

assert_eq!(
    format!("{:?}", arr1),
    format!("{:?}", arr2)
);

Make with_timezone method accept both &str and String values.
Add a method to PrimitiveArray<T: ArrowTimestampType> for using UTC as
the timezone.
@github-actions github-actions bot added the arrow Changes to the arrow crate label Nov 11, 2022
Copy link
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.

Looks great -- thank you @src255

cc @waitingkuo

@@ -779,8 +779,13 @@ 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))
pub fn with_timezone(&self, timezone: impl Into<String>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @src255 @alamb

@alamb alamb changed the title Issue 3042 Improved UX of creating TimestampNanosecondArray with timezones Nov 11, 2022
@tustvold
Copy link
Contributor

I took the liberty of resolving the merge conflicts on this

@tustvold tustvold merged commit 561f63a into apache:master Nov 11, 2022
@ursabot
Copy link

ursabot commented Nov 11, 2022

Benchmark runs are scheduled for baseline = 02a3f5c and contender = 561f63a. 561f63a 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

@src255
Copy link
Contributor Author

src255 commented Nov 12, 2022

@tustvold Thank you for resolving the merge conflicts, I really appreciate it!

@src255 src255 deleted the issue_3042 branch November 12, 2022 02:59
@alamb
Copy link
Contributor

alamb commented Nov 12, 2022

Great team effort 👍

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.

Improved UX of creating TimestampNanosecondArray with timezones
5 participants