andygrove commented on code in PR #615:
URL: https://github.com/apache/datafusion-comet/pull/615#discussion_r1677921910


##########
native/spark-expr/src/cast.rs:
##########
@@ -475,6 +476,27 @@ macro_rules! cast_decimal_to_int32_up {
     }};
 }
 
+macro_rules! cast_utf8_to_decimal {
+    ($array:expr, $precision:expr, $scale:expr, $eval_mode:expr, 
$array_type:ty, $cast_method:ident) => {{
+        let len = $array.len();
+        let mut cast_array = PrimitiveArray::<$array_type>::builder(len)
+            .with_precision_and_scale($precision, $scale)?;
+        for i in 0..len {
+            if $array.is_null(i) {
+                cast_array.append_null()
+            } else if let Some(cast_value) =
+                $cast_method($array.value(i).trim(), $precision, $scale, 
$eval_mode)?
+            {
+                cast_array.append_value(cast_value);
+            } else {
+                cast_array.append_null()
+            }
+        }
+        let result: SparkResult<ArrayRef> = Ok(Arc::new(cast_array.finish()) 
as ArrayRef);
+        result?

Review Comment:
   No need to wrap in a result and then unwrap.
   
   ```suggestion
           Arc::new(cast_array.finish()) as ArrayRef
   ```



-- 
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]

Reply via email to