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

Support extract day and month in temporal.rs #1388

Merged
merged 5 commits into from Mar 4, 2022

Conversation

Ted-Jiang
Copy link
Member

Which issue does this PR close?

Closes #1387 .

@github-actions github-actions bot added the arrow Changes to the arrow crate label Mar 3, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2022

Codecov Report

Merging #1388 (00d71b5) into master (6ee51bc) will increase coverage by 0.05%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1388      +/-   ##
==========================================
+ Coverage   82.99%   83.05%   +0.05%     
==========================================
  Files         181      181              
  Lines       52933    53076     +143     
==========================================
+ Hits        43932    44082     +150     
+ Misses       9001     8994       -7     
Impacted Files Coverage Δ
arrow/src/compute/kernels/temporal.rs 97.13% <96.96%> (-0.22%) ⬇️
parquet/src/encodings/encoding.rs 93.52% <0.00%> (-0.20%) ⬇️
parquet_derive/src/parquet_field.rs 66.21% <0.00%> (+0.22%) ⬆️
arrow/src/compute/kernels/comparison.rs 92.45% <0.00%> (+0.29%) ⬆️
parquet/src/file/metadata.rs 94.42% <0.00%> (+0.54%) ⬆️
arrow/src/record_batch.rs 94.00% <0.00%> (+2.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6ee51bc...00d71b5. Read the comment docs.

let mut b = Int32Builder::new(array.len());
match array.data_type() {
&DataType::Date32 | &DataType::Date64 | &DataType::Timestamp(_, _) => {
extract_component_from_array!(array, b, month, value_as_datetime)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the timezone will impact hour, day, month, year and other time unit which are higher than hour.

Copy link
Contributor

Choose a reason for hiding this comment

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

For example:
2020-01-01 07:00:00 UTC0
The format at UTC-8 is 2019-12-31 23:00:00 and the year, month, day, hour are all changed.
@Ted-Jiang

Copy link
Member Author

Choose a reason for hiding this comment

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

Already add timezone support

@Ted-Jiang Ted-Jiang marked this pull request as draft March 3, 2022 07:27
@Ted-Jiang Ted-Jiang changed the title Add extract month in temporal.rs Add extract month and day in temporal.rs Mar 3, 2022
@Ted-Jiang Ted-Jiang marked this pull request as ready for review March 3, 2022 07:57
@Ted-Jiang Ted-Jiang closed this Mar 3, 2022
@Ted-Jiang Ted-Jiang reopened this Mar 3, 2022
@Ted-Jiang Ted-Jiang closed this Mar 3, 2022
@Ted-Jiang Ted-Jiang reopened this Mar 3, 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 good to me. Thank you @Ted-Jiang

Any other thoughts @liukun4515 ?

&DataType::Date32 | &DataType::Date64 | &DataType::Timestamp(_, None) => {
extract_component_from_array!(array, b, month, value_as_datetime)
}
&DataType::Timestamp(_, Some(ref tz)) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Some("-10:00".to_string()),
));
let b = month(&a).unwrap();
assert_eq!(1, b.value(0));
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Some("-10:00".to_string()),
));
let b = day(&a).unwrap();
assert_eq!(1, b.value(0));
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

@liukun4515 liukun4515 left a comment

Choose a reason for hiding this comment

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

LGTM
@alamb you can merge it.
It's nice for datafusion, if this pr can be merged before 10.0.0 release.

@liukun4515 liukun4515 mentioned this pull request Mar 4, 2022
@alamb alamb merged commit afcf304 into apache:master Mar 4, 2022
@alamb
Copy link
Contributor

alamb commented Mar 4, 2022

Thanks @Ted-Jiang @nevi-me and @liukun4515 !

@alamb alamb changed the title Add extract month and day in temporal.rs Support extract day and month in temporal.rs Mar 4, 2022
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.

Add extract month and day in temporal.rs
5 participants