alamb commented on code in PR #7648:
URL: https://github.com/apache/arrow-datafusion/pull/7648#discussion_r1336318411


##########
datafusion/sql/src/expr/value.rs:
##########
@@ -55,35 +56,36 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
     }
 
     /// Parse number in sql string, convert to Expr::Literal
-    fn parse_sql_number(&self, n: &str) -> Result<Expr> {
-        if let Ok(n) = n.parse::<i64>() {
-            Ok(lit(n))
-        } else if let Ok(n) = n.parse::<u64>() {
-            Ok(lit(n))
-        } else if self.options.parse_float_as_decimal {
-            // remove leading zeroes
-            let str = n.trim_start_matches('0');
-            if let Some(i) = str.find('.') {
-                let p = str.len() - 1;
-                let s = str.len() - i - 1;
-                let str = str.replace('.', "");
-                let n = parse_decimal_128_without_scale(&str)?;
-                Ok(Expr::Literal(ScalarValue::Decimal128(
-                    Some(n),
-                    p as u8,
-                    s as i8,
-                )))
-            } else {
-                let number = parse_decimal_128_without_scale(str)?;
-                Ok(Expr::Literal(ScalarValue::Decimal128(
-                    Some(number),
-                    str.len() as u8,
-                    0,
-                )))
+    pub(super) fn parse_sql_number(

Review Comment:
   This is a very nice cleanup -- thank you @jonahgao 



##########
datafusion/sqllogictest/test_files/options.slt:
##########
@@ -84,69 +84,129 @@ statement ok
 drop table a
 
 # test datafusion.sql_parser.parse_float_as_decimal
+# 
 # default option value is false
-query R
-select 10000000000000000000.01
+query RR
+select 10000000000000000000.01, -10000000000000000000.01
 ----
-10000000000000000000
+10000000000000000000 -10000000000000000000 
 
-query T
-select arrow_typeof(10000000000000000000.01)
+query TT
+select arrow_typeof(10000000000000000000.01), 
arrow_typeof(-10000000000000000000.01)
+----
+Float64 Float64

Review Comment:
   👍 



##########
datafusion/sqllogictest/test_files/options.slt:
##########
@@ -84,69 +84,129 @@ statement ok
 drop table a
 
 # test datafusion.sql_parser.parse_float_as_decimal
+# 
 # default option value is false
-query R
-select 10000000000000000000.01
+query RR
+select 10000000000000000000.01, -10000000000000000000.01
 ----
-10000000000000000000
+10000000000000000000 -10000000000000000000 
 
-query T
-select arrow_typeof(10000000000000000000.01)
+query TT
+select arrow_typeof(10000000000000000000.01), 
arrow_typeof(-10000000000000000000.01)
+----
+Float64 Float64

Review Comment:
   👍 



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

Reply via email to