andygrove commented on code in PR #1914: URL: https://github.com/apache/datafusion-comet/pull/1914#discussion_r2164429663
########## native/spark-expr/src/conversion_funcs/cast.rs: ########## @@ -1298,6 +1298,7 @@ where }); } else { cast_array.append_null(); + continue; Review Comment: > If you mean code quality/style, how about the follow one: > > ```rust > for i in 0..input.len() { > if input.is_null(i) { > cast_array.append_null(); > continue; > } > > let input_value = input.value(i).as_(); > if let Some(v) = (input_value * mul).round().to_i128() { > if Decimal128Type::validate_decimal_precision(v, precision).is_ok() { > cast_array.append_value(v); > continue; > } > }; > > if eval_mode == EvalMode::Ansi { > return Err(SparkError::NumericValueOutOfRange { > value: input_value.to_string(), > precision, > scale, > }); > } > cast_array.append_null(); > } > ``` Yes, this is easier to follow. You could call `is_validate_decimal_precision` rather than checking for a Result on `validate_decimal_precision` and it should be more efficient. -- 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