kumarUjjawal commented on code in PR #19831:
URL: https://github.com/apache/datafusion/pull/19831#discussion_r2701242996
##########
datafusion/functions/src/math/round.rs:
##########
@@ -434,4 +494,140 @@ mod test {
Err(DataFusionError::ArrowError(_, _)) |
Err(DataFusionError::Execution(_))
));
}
+
+ // Tests for scalar fast path
+ use super::RoundFunc;
+ use arrow::datatypes::{DataType, Field};
+ use datafusion_common::config::ConfigOptions;
+ use datafusion_expr::{ScalarFunctionArgs, ScalarUDFImpl};
+
+ fn round_scalar(
+ value: ScalarValue,
+ decimal_places: Option<i32>,
+ ) -> Result<ScalarValue, DataFusionError> {
+ let round_func = RoundFunc::new();
+ let config_options = Arc::new(ConfigOptions::default());
+
+ let dp = decimal_places.unwrap_or(0);
+ let args = vec![
+ ColumnarValue::Scalar(value.clone()),
+ ColumnarValue::Scalar(ScalarValue::Int32(Some(dp))),
+ ];
+
+ let return_type = round_func.return_type(&[value.data_type()])?;
+
+ let result = round_func.invoke_with_args(ScalarFunctionArgs {
+ args,
+ arg_fields: vec![
+ Field::new("a", value.data_type(), true).into(),
+ Field::new("b", DataType::Int32, false).into(),
+ ],
+ number_rows: 1,
+ return_field: Field::new("f", return_type, true).into(),
+ config_options,
+ })?;
+
+ match result {
+ ColumnarValue::Scalar(s) => Ok(s),
+ ColumnarValue::Array(a) => ScalarValue::try_from_array(&a, 0),
+ }
+ }
+
+ #[test]
+ fn test_round_scalar_f64() {
Review Comment:
Removed the scalar unit tests, these are already tested in the SLTs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]