From 2fc34f00ed7fd035c403eb62142a4ce75ebf7fea Mon Sep 17 00:00:00 2001 From: George Date: Tue, 14 Jun 2022 17:52:34 +0800 Subject: [PATCH] add tests --- datafusion/sql/src/planner.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rs index 1874eb30cf46..d8df55d9acec 100644 --- a/datafusion/sql/src/planner.rs +++ b/datafusion/sql/src/planner.rs @@ -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";