viirya commented on code in PR #4102:
URL: https://github.com/apache/arrow-datafusion/pull/4102#discussion_r1013529771


##########
datafusion/sql/src/planner.rs:
##########
@@ -2671,6 +2694,49 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
             Ok(lit(ScalarValue::new_list(Some(values), data_type)))
         }
     }
+
+    /// Parse number in sql string, convert to Expr::Literal
+    fn parse_sql_number(&self, n: &str) -> Result<Expr> {
+        if let Some(_) = n.find('E') {
+            // not implemented yet
+            // https://github.com/apache/arrow-datafusion/issues/3448
+            Err(DataFusionError::NotImplemented(
+                "sql numeric literals in scientific notation are not supported"
+                    .to_string(),
+            ))
+        } else if let Ok(n) = n.parse::<i64>() {
+            Ok(lit(n))
+        } else if self.options.parse_float_as_decimal {
+            if let Some(i) = n.find('.') {
+                let p = n.len() - 1;
+                let s = n.len() - i - 1;
+                let str = n.replace('.', "");
+                let n = str.parse::<i128>().map_err(|_| {
+                    DataFusionError::from(ParserError(format!(
+                        "Cannot parse {} as i128 when building decimal",
+                        str

Review Comment:
   Maybe good to print out original string too, i.e.,
   
   ```suggestion
                           "Cannot parse {} as i128 when building decimal. 
Input token: {}",
                           str, n
   ```



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