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


##########
native/spark-expr/src/conversion_funcs/cast.rs:
##########
@@ -1298,6 +1298,7 @@ where
                             });
                         } else {
                             cast_array.append_null();
+                            continue;

Review Comment:
   Thanks for catching the bug @leung-ming - the code can currently append both 
a null and a value, which is incorrect.
   
   However, using `continue` does not seem to be the correct fix because if 
will terminate the `for` loop and stop processing the remaining data in the 
vector. 
   
   I think we just need an `else` condition instead:
   
   ```rust
                       if Decimal128Type::validate_decimal_precision(v, 
precision).is_err() {
                           if eval_mode == EvalMode::Ansi {
                               return Err(SparkError::NumericValueOutOfRange {
                                   value: input_value.to_string(),
                                   precision,
                                   scale,
                               });
                           } else {
                               cast_array.append_null();
                           }
                       } else {
                           cast_array.append_value(v);
                       }
   ```                    



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