Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gandronchik committed Jun 14, 2022
1 parent 06fd7c7 commit 2fc34f0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions datafusion/sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,25 @@ mod tests {
);
}

#[test]
fn test_int_decimal_no_scale() {
quick_test(
"SELECT CAST(10 AS DECIMAL(5))",
"Projection: CAST(Int64(10) AS Decimal(5, 0))\
\n EmptyRelation",
);
}

#[test]
fn test_int_decimal_scale_larger_precision() {
let sql = "SELECT CAST(10 AS DECIMAL(5, 10))";
let err = logical_plan(sql).expect_err("query should have failed");
assert_eq!(
r##"Internal("For decimal(precision, scale) precision must be less than or equal to 38 and scale can't be greater than precision. Got (5, 10)")"##,
format!("{:?}", err)
);
}

#[test]
fn select_column_does_not_exist() {
let sql = "SELECT doesnotexist FROM person";
Expand Down

0 comments on commit 2fc34f0

Please sign in to comment.