alamb commented on code in PR #8494:
URL: https://github.com/apache/arrow-datafusion/pull/8494#discussion_r1427258253
##########
datafusion/sqllogictest/test_files/options.slt:
##########
@@ -206,6 +206,18 @@ select 123456789.0123456789012345678901234567890
statement error SQL error: ParserError\("Cannot parse
1234567890123456789012345678901234567890 as i128 when building decimal: number
too large to fit in target type"\)
select -123456789.0123456789012345678901234567890
+# scientific notation
+query RRRR
+select 1.234e2, 1.234e-2, -1.234e2, -1.234e-2
Review Comment:
`1.234e-2` is not `-123.4` I don't think 🤔
```
DataFusion CLI v33.0.0
❯ select 1.234e-2;
+------------------+
| Float64(0.01234) |
+------------------+
| 0.01234 |
+------------------+
```
##########
datafusion/sql/src/expr/value.rs:
##########
@@ -405,11 +405,29 @@ const fn try_decode_hex_char(c: u8) -> Option<u8> {
}
/// Parse Decimal128 from a string
-///
-/// TODO: support parsing from scientific notation
fn parse_decimal_128(unsigned_number: &str, negative: bool) -> Result<Expr> {
// remove leading zeroes
let trimmed = unsigned_number.trim_start_matches('0');
+
+ // check if the number is scientific notation
+ let parts = trimmed.split(|c| c == 'e' || c == 'E').collect::<Vec<_>>();
Review Comment:
It seems like `BigDecimal::from_str` handles scientific notation --
https://docs.rs/bigdecimal/latest/bigdecimal/struct.BigDecimal.html#examples
Since it is already a dependency, perhaps we can switch to using its
implementation of parsing?
--
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]