Skip to content

Commit

Permalink
Merge 98a67c5 into 5778ef2
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingkuo committed Aug 15, 2022
2 parents 5778ef2 + 98a67c5 commit 67e8355
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions datafusion/core/tests/sql/timestamp.rs
Expand Up @@ -1433,3 +1433,35 @@ async fn timestamp_array_add_interval() -> Result<()> {
assert_batches_eq!(expected, &actual);
Ok(())
}

#[tokio::test]
async fn cast_timestamp_before_1970() -> Result<()> {
// this is a repro for issue #3082
let ctx = SessionContext::new();

let sql = "select cast('1969-01-01T00:00:00Z' as timestamp);";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+-------------------------------------------------------------------+",
"| CAST(Utf8(\"1969-01-01T00:00:00Z\") AS Timestamp(Nanosecond, None)) |",
"+-------------------------------------------------------------------+",
"| 1969-01-01 00:00:00 |",
"+-------------------------------------------------------------------+",
];

assert_batches_eq!(expected, &actual);

let sql = "select cast('1969-01-01T00:00:00.1Z' as timestamp);";
let actual = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+---------------------------------------------------------------------+",
"| CAST(Utf8(\"1969-01-01T00:00:00.1Z\") AS Timestamp(Nanosecond, None)) |",
"+---------------------------------------------------------------------+",
"| 1969-01-01 00:00:00.100 |",
"+---------------------------------------------------------------------+",
];

assert_batches_eq!(expected, &actual);

Ok(())
}

0 comments on commit 67e8355

Please sign in to comment.