tlm365 commented on code in PR #1728:
URL: https://github.com/apache/datafusion-comet/pull/1728#discussion_r2082843668


##########
native/spark-expr/src/math_funcs/ceil.rs:
##########
@@ -81,3 +81,162 @@ fn decimal_ceil_f(scale: &i8) -> impl Fn(i128) -> i128 {
     let div = 10_i128.pow_wrapping(*scale as u32);
     move |x: i128| div_ceil(x, div)
 }
+
+#[cfg(test)]
+mod test {
+    use crate::spark_ceil;
+    use arrow::array::{Decimal128Array, Float32Array, Float64Array, 
Int64Array};
+    use arrow::datatypes::DataType;
+    use datafusion::common::cast::as_int64_array;
+    use datafusion::common::{Result, ScalarValue};
+    use datafusion::physical_plan::ColumnarValue;
+    use std::sync::Arc;
+
+    #[test]
+    fn test_ceil_f32_array() -> Result<()> {
+        let input = Float32Array::from(vec![
+            Some(125.2345),
+            Some(15.0001),
+            Some(0.1),
+            Some(-0.9),
+            Some(-1.1),
+            Some(123.0),
+            None,
+        ]);
+        let args = vec![ColumnarValue::Array(Arc::new(input))];
+        let ColumnarValue::Array(result) = spark_ceil(&args, 
&DataType::Float32)? else {
+            unreachable!()
+        };
+        let actual = as_int64_array(&result)?;
+        let expected = Int64Array::from(vec![
+            Some(126),
+            Some(16),
+            Some(1),
+            Some(0),
+            Some(-1),
+            Some(123),
+            None,
+        ]);
+        assert_eq!(actual, &expected);
+        Ok(())
+    }
+
+    #[test]
+    fn test_ceil_f64_array() -> Result<()> {
+        let input = Float64Array::from(vec![
+            Some(125.2345),
+            Some(15.0001),
+            Some(0.1),
+            Some(-0.9),
+            Some(-1.1),
+            Some(123.0),
+            None,
+        ]);
+        let args = vec![ColumnarValue::Array(Arc::new(input))];
+        let ColumnarValue::Array(result) = spark_ceil(&args, 
&DataType::Float64)? else {
+            unreachable!()
+        };
+        let actual = as_int64_array(&result)?;
+        let expected = Int64Array::from(vec![
+            Some(126),
+            Some(16),
+            Some(1),
+            Some(0),
+            Some(-1),
+            Some(123),
+            None,
+        ]);
+        assert_eq!(actual, &expected);
+        Ok(())
+    }
+
+    #[test]
+    fn test_ceil_i64_array() -> Result<()> {
+        let input = Int64Array::from(vec![Some(-1), Some(0), Some(1), None]);
+        let args = vec![ColumnarValue::Array(Arc::new(input))];
+        let ColumnarValue::Array(result) = spark_ceil(&args, 
&DataType::Int64)? else {
+            unreachable!()
+        };
+        let actual = as_int64_array(&result)?;
+        let expected = Int64Array::from(vec![Some(-1), Some(0), Some(1), 
None]);
+        assert_eq!(actual, &expected);
+        Ok(())
+    }
+
+    #[test]
+    fn test_ceil_decimal128_array() -> Result<()> {

Review Comment:
   This test (and other tests for `Decimal128` datatype) is not pass. It seems 
like a bug 🤔



-- 
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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to