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 cast timestamp to time #3016

Merged
merged 8 commits into from
Nov 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comment test
naosense committed Nov 8, 2022
commit effe146a845d14635896c7339665e56a86b50518
12 changes: 10 additions & 2 deletions arrow-cast/src/cast.rs
Original file line number Diff line number Diff line change
@@ -4235,6 +4235,7 @@ mod tests {

#[test]
fn test_cast_timestamp_to_time64() {
// test timestamp secs
let a = TimestampSecondArray::from(vec![Some(86405), Some(1), None])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;
@@ -4249,6 +4250,7 @@ mod tests {
assert_eq!(1000000000, c.value(1));
assert!(c.is_null(2));

// test timestamp milliseconds
let a = TimestampMillisecondArray::from(vec![Some(86405000), Some(1000), None])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;
@@ -4263,6 +4265,7 @@ mod tests {
assert_eq!(1000000000, c.value(1));
assert!(c.is_null(2));

// test timestamp microseconds
let a =
TimestampMicrosecondArray::from(vec![Some(86405000000), Some(1000000), None])
.with_timezone("UTC".to_string());
@@ -4278,6 +4281,7 @@ mod tests {
assert_eq!(1000000000, c.value(1));
assert!(c.is_null(2));

// test timestamp nanoseconds
let a = TimestampNanosecondArray::from(vec![
Some(86405000000000),
Some(1000000000),
@@ -4296,7 +4300,7 @@ mod tests {
assert_eq!(1000000000, c.value(1));
assert!(c.is_null(2));

// overflow
// test overflow
let a = TimestampSecondArray::from(vec![Some(i64::MAX)])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;
@@ -4308,6 +4312,7 @@ mod tests {

#[test]
fn test_cast_timestamp_to_time32() {
// test timestamp secs
let a = TimestampSecondArray::from(vec![Some(86405), Some(1), None])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;
@@ -4322,6 +4327,7 @@ mod tests {
assert_eq!(1000, c.value(1));
assert!(c.is_null(2));

// test timestamp milliseconds
let a = TimestampMillisecondArray::from(vec![Some(86405000), Some(1000), None])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;
@@ -4336,6 +4342,7 @@ mod tests {
assert_eq!(1000, c.value(1));
assert!(c.is_null(2));

// test timestamp microseconds
let a =
TimestampMicrosecondArray::from(vec![Some(86405000000), Some(1000000), None])
.with_timezone("UTC".to_string());
@@ -4351,6 +4358,7 @@ mod tests {
assert_eq!(1000, c.value(1));
assert!(c.is_null(2));

// test timestamp nanoseconds
let a = TimestampNanosecondArray::from(vec![
Some(86405000000000),
Some(1000000000),
@@ -4369,7 +4377,7 @@ mod tests {
assert_eq!(1000, c.value(1));
assert!(c.is_null(2));

// overflow
// test overflow
let a = TimestampSecondArray::from(vec![Some(i64::MAX)])
.with_timezone("UTC".to_string());
let array = Arc::new(a) as ArrayRef;