himadripal commented on issue #10315:
URL: https://github.com/apache/datafusion/issues/10315#issuecomment-2551863649

   I'm working on this issue and need help here -
   I added test case to debug, at the moment string to decimal conversion is 
using 
[parse_string_to_decimal_native](https://github.com/apache/arrow-rs/blob/fc814bca6b743010bcde972e611c8ff8ea68c9f5/arrow-cast/src/cast/decimal.rs#L235),
 I did not find support for `e` notation in this, but there is a function  
[parse_decimal](https://github.com/apache/arrow-rs/blob/fc814bca6b743010bcde972e611c8ff8ea68c9f5/arrow-cast/src/parse.rs#L837)
 that does support e-notation.I changed the code to use parse_decimal and it 
works fine for cases with 4e+7 and looks like there is a bug in the 
[parse_decimal](https://github.com/apache/arrow-rs/blob/fc814bca6b743010bcde972e611c8ff8ea68c9f5/arrow-cast/src/parse.rs#L837)
  when i provide 4e7 without + or -, for example this test case -
   ```rust
   #[test]
   fn test_cast_with_options_utf8_to_decimal() {
       let array = StringArray::from(vec!["4e+7"]);
       let result = cast_with_options(
           &array,
           &DataType::Decimal128(10,2),
           &CastOptions {
               safe: false,
               format_options: FormatOptions::default(),
           },
       ).unwrap();
       let output_array = result.as_any().downcast_ref::<Decimal128Array>();
       assert_eq!(output_array.unwrap().value(0) , 4000000);
   }
   returns 4000000000  so it expands till the precision value.
   ```
   Can anyone clarify -  should we replace 
[parse_string_to_decimal_native](https://github.com/apache/arrow-rs/blob/fc814bca6b743010bcde972e611c8ff8ea68c9f5/arrow-cast/src/cast/decimal.rs#L235C15-L235C45)
 with 
[parse_decimal](https://github.com/apache/arrow-rs/blob/fc814bca6b743010bcde972e611c8ff8ea68c9f5/arrow-cast/src/parse.rs#L837)
 and fix this bug there? 


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