-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Timezone to Scalar::Time* types, and better timezone awareness to Datafusion's time types #1455
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
Changes from all commits
10fd537
a1e8e8a
1093c58
5fd5bf1
dc800e1
1f500c7
0bd6c26
e782fe7
118c487
602c1b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,11 +100,48 @@ pub fn like_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp | |||||||||||||||||
| /// casted to for the purpose of a date computation | ||||||||||||||||||
| pub fn temporal_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataType> { | ||||||||||||||||||
| use arrow::datatypes::DataType::*; | ||||||||||||||||||
| use arrow::datatypes::TimeUnit; | ||||||||||||||||||
| match (lhs_type, rhs_type) { | ||||||||||||||||||
| (Utf8, Date32) => Some(Date32), | ||||||||||||||||||
| (Date32, Utf8) => Some(Date32), | ||||||||||||||||||
| (Utf8, Date64) => Some(Date64), | ||||||||||||||||||
| (Date64, Utf8) => Some(Date64), | ||||||||||||||||||
| (Timestamp(lhs_unit, lhs_tz), Timestamp(rhs_unit, rhs_tz)) => { | ||||||||||||||||||
| let tz = match (lhs_tz, rhs_tz) { | ||||||||||||||||||
| // can't cast across timezones | ||||||||||||||||||
| (Some(lhs_tz), Some(rhs_tz)) => { | ||||||||||||||||||
| if lhs_tz != rhs_tz { | ||||||||||||||||||
| return None; | ||||||||||||||||||
| } else { | ||||||||||||||||||
| Some(lhs_tz.clone()) | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| (Some(lhs_tz), None) => Some(lhs_tz.clone()), | ||||||||||||||||||
| (None, Some(rhs_tz)) => Some(rhs_tz.clone()), | ||||||||||||||||||
| (None, None) => None, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| let unit = match (lhs_unit, rhs_unit) { | ||||||||||||||||||
| (TimeUnit::Second, TimeUnit::Millisecond) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Second, TimeUnit::Microsecond) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Second, TimeUnit::Nanosecond) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Millisecond, TimeUnit::Second) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Millisecond, TimeUnit::Microsecond) => TimeUnit::Millisecond, | ||||||||||||||||||
| (TimeUnit::Millisecond, TimeUnit::Nanosecond) => TimeUnit::Millisecond, | ||||||||||||||||||
| (TimeUnit::Microsecond, TimeUnit::Second) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Microsecond, TimeUnit::Millisecond) => TimeUnit::Millisecond, | ||||||||||||||||||
| (TimeUnit::Microsecond, TimeUnit::Nanosecond) => TimeUnit::Microsecond, | ||||||||||||||||||
| (TimeUnit::Nanosecond, TimeUnit::Second) => TimeUnit::Second, | ||||||||||||||||||
| (TimeUnit::Nanosecond, TimeUnit::Millisecond) => TimeUnit::Millisecond, | ||||||||||||||||||
| (TimeUnit::Nanosecond, TimeUnit::Microsecond) => TimeUnit::Microsecond, | ||||||||||||||||||
| (l, r) => { | ||||||||||||||||||
| assert_eq!(l, r); | ||||||||||||||||||
| l.clone() | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+137
to
+140
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried this but we need an which is semantically identical, but the version with |
||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| Some(Timestamp(unit, tz)) | ||||||||||||||||||
| } | ||||||||||||||||||
| _ => None, | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍