From 6bdbb72b447dcba75acb22f85e85b1b172eeab00 Mon Sep 17 00:00:00 2001 From: Xiangpeng Hao Date: Fri, 26 Jul 2024 09:21:42 -0400 Subject: [PATCH] add tests --- datafusion/functions/src/utils.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/datafusion/functions/src/utils.rs b/datafusion/functions/src/utils.rs index 45662dfabf36..7b367174006d 100644 --- a/datafusion/functions/src/utils.rs +++ b/datafusion/functions/src/utils.rs @@ -183,6 +183,21 @@ pub mod test { }; } + use arrow::datatypes::DataType; #[allow(unused_imports)] pub(crate) use test_function; + + use super::*; + + #[test] + fn string_to_int_type() { + let v = utf8_to_int_type(&DataType::Utf8, "test").unwrap(); + assert_eq!(v, DataType::Int32); + + let v = utf8_to_int_type(&DataType::Utf8View, "test").unwrap(); + assert_eq!(v, DataType::Int32); + + let v = utf8_to_int_type(&DataType::LargeUtf8, "test").unwrap(); + assert_eq!(v, DataType::Int64); + } }