andygrove commented on code in PR #615:
URL: https://github.com/apache/datafusion-comet/pull/615#discussion_r1676467290
##########
core/src/execution/datafusion/expressions/cast.rs:
##########
@@ -1208,6 +1277,260 @@ fn do_cast_string_to_int<
Ok(Some(result))
}
+fn cast_string_to_decimal128(
+ str: &str,
+ precision: u8,
+ scale: i8,
+ eval_mode: EvalMode,
+) -> CometResult<Option<i128>> {
+ let cast = match parse_decimal::<Decimal128Type>(str, precision, scale) {
+ Some(v) => v,
+ None => {
+ if eval_mode == EvalMode::Ansi {
+ let type_name = format!("DECIMAL({},{})", precision, scale);
+ return none_or_err(eval_mode, &type_name, str);
+ } else {
+ return Ok(None);
+ }
+ }
+ };
+ Ok(Some(cast))
+}
+
+fn cast_string_to_decimal256(
+ str: &str,
+ precision: u8,
+ scale: i8,
+ eval_mode: EvalMode,
+) -> CometResult<Option<i256>> {
+ let cast = match parse_decimal::<Decimal256Type>(str, precision, scale) {
+ Some(v) => v,
+ None => {
+ if eval_mode == EvalMode::Ansi {
+ let type_name = format!("DECIMAL({},{})", precision, scale);
+ return none_or_err(eval_mode, &type_name, str);
+ } else {
+ return Ok(None);
+ }
+ }
+ };
+ Ok(Some(cast))
+}
+
+/// Copied from arrow-rs, modified to replicate Spark's behavior
Review Comment:
This comment is useful, thanks. Could you also update the comment to give a
brief summary of what needed to change to replicate Spark's behavior?
--
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]