Skip to content

Improved UX of creating TimestampNanosecondArray with timezones#3088

Merged
tustvold merged 3 commits into
apache:masterfrom
src255:issue_3042
Nov 11, 2022
Merged

Improved UX of creating TimestampNanosecondArray with timezones#3088
tustvold merged 3 commits into
apache:masterfrom
src255:issue_3042

Conversation

@src255

@src255 src255 commented Nov 11, 2022

Copy link
Copy Markdown
Contributor

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

@alamb alamb 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.

Looks great -- thank you @src255

cc @waitingkuo

/// 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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❤️

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.

Thank you @src255 @alamb

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

Copy link
Copy Markdown
Contributor

I took the liberty of resolving the merge conflicts on this

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

ursabot commented Nov 11, 2022

Copy link
Copy Markdown

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

src255 commented Nov 12, 2022

Copy link
Copy Markdown
Contributor Author

@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

alamb commented Nov 12, 2022

Copy link
Copy Markdown
Contributor

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