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


##########
datafusion/sql/src/planner.rs:
##########
@@ -2678,9 +2683,13 @@ pub fn convert_data_type(sql_type: &SQLDataType) -> 
Result<DataType> {
 
 // Parse number in sql string, convert to Expr::Literal
 fn parse_sql_number(n: &str) -> Result<Expr> {
-    match n.parse::<i64>() {
-        Ok(n) => Ok(lit(n)),
-        Err(_) => Ok(lit(n.parse::<f64>().unwrap())),
+    match (n.parse::<i64>(), n.parse::<f64>()) {
+        (Ok(n), _) => Ok(lit(n)),
+        (Err(_), Ok(n)) => Ok(lit(n)),
+        (Err(_), Err(_)) => Err(DataFusionError::from(ParserError(format!(
+            "Cannot parse {} as i64 or f64",
+            n
+        )))),
     }

Review Comment:
   Here is an alternate proposal of (yet) another way to do it: 
https://github.com/apache/arrow-datafusion/pull/3432



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