Skip to content

Commit

Permalink
add more tests and refine error info
Browse files Browse the repository at this point in the history
  • Loading branch information
Weijun-H committed Mar 12, 2023
1 parent 4117ed8 commit 61a86d1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
17 changes: 9 additions & 8 deletions datafusion/core/tests/sql/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1315,18 +1315,19 @@ async fn test_extract_date_part() -> Result<()> {

#[tokio::test]
async fn test_extract_epoch() -> Result<()> {
// test_expression!(
// "extract(epoch from '2070-01-01T07:29:10.256'::timestamp)",
// "-4554981058.744"
// );
// test_expression!(
// "extract(epoch from '2000-01-01T00:00:00.000'::timestamp)",
// "946684800.0"
// );
test_expression!(
"extract(epoch from '1870-01-01T07:29:10.256'::timestamp)",
"-3155646649.744"
);
test_expression!(
"extract(epoch from '2000-01-01T00:00:00.000'::timestamp)",
"946684800.0"
);
test_expression!(
"extract(epoch from to_timestamp('2000-01-01T00:00:00+00:00'))",
"946684800.0"
);
test_expression!("extract(epoch from NULL::timestamp)", "NULL");
Ok(())
}

Expand Down
7 changes: 6 additions & 1 deletion datafusion/physical-expr/src/datetime_expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,12 @@ where
}
}
}
_ => return Err(DataFusionError::Internal("Invalid data type".to_string())),
_ => {
return Err(DataFusionError::Internal(format!(
"Can not convert {:?} to epoch",
array.data_type()
)))
}
}
Ok(b.finish())
}
Expand Down

0 comments on commit 61a86d1

Please sign in to comment.