Skip to content

Commit

Permalink
add some test cases for time
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingkuo committed Jul 24, 2023
1 parent b135a96 commit 79f50a4
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions datafusion/core/tests/sql/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,53 @@ async fn timestamp_sub_with_tz() -> Result<()> {

Ok(())
}

async fn time_comparison() -> Result<()> {
let ctx = SessionContext::new();

let sql = "SELECT TIME '00:00:00' = TIME '00:00:00'";
let results = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+--------------------------------------------------------------------------------------------+",
"| CAST(Utf8(\"00:00:00\") AS Time64(Nanosecond)) = CAST(Utf8(\"00:00:00\") AS Time64(Nanosecond))|",
"+--------------------------------------------------------------------------------------------+",
"| true |",
"+--------------------------------------------------------------------------------------------+",
];
assert_batches_eq!(expected, &results);

let sql = "SELECT TIME '00:00:00' = TIME '00:00:01'";
let results = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+--------------------------------------------------------------------------------------------+",
"| CAST(Utf8(\"00:00:00\") AS Time64(Nanosecond)) = CAST(Utf8(\"00:00:01\") AS Time64(Nanosecond))|",
"+--------------------------------------------------------------------------------------------+",
"| false |",
"+--------------------------------------------------------------------------------------------+",
];
assert_batches_eq!(expected, &results);

let sql = "SELECT TIME '00:00:00' < TIME '00:00:01'";
let results = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+--------------------------------------------------------------------------------------------+",
"| CAST(Utf8(\"00:00:00\") AS Time64(Nanosecond)) < CAST(Utf8(\"00:00:01\") AS Time64(Nanosecond))|",
"+--------------------------------------------------------------------------------------------+",
"| true |",
"+--------------------------------------------------------------------------------------------+",
];
assert_batches_eq!(expected, &results);

let sql = "SELECT TIME '00:00:00' > TIME '00:00:01'";
let results = execute_to_batches(&ctx, sql).await;
let expected = vec![
"+--------------------------------------------------------------------------------------------+",
"| CAST(Utf8(\"00:00:00\") AS Time64(Nanosecond)) > CAST(Utf8(\"00:00:01\") AS Time64(Nanosecond))|",
"+--------------------------------------------------------------------------------------------+",
"| false |",
"+--------------------------------------------------------------------------------------------+",
];
assert_batches_eq!(expected, &results);

Ok(())
}

0 comments on commit 79f50a4

Please sign in to comment.