nuno-faria opened a new issue, #23877:
URL: https://github.com/apache/datafusion/issues/23877

   ### Describe the bug
   
   Numeric literals with underscores fail to get parsed, even though they are 
supported by some dialects. The problem is that the [`parse_sql_number`]( 
https://github.com/apache/datafusion/blob/f1ab86dad406a189e43ac19d24965b3fbf9dbba9/datafusion/sql/src/expr/value.rs#L72)
 method uses Rust's `parse`, which treats underscores as errors 
(https://doc.rust-lang.org/core/primitive.i64.html#method.from_str).
   
   This is pretty easy to fix, we just need to remove the underscores before 
parsing. The positive number cases will require an additional string allocation 
that they didn't need before, but this should be ok since I think it's only 
used to parse SQL code. However, I want to know whether to apply the fix here 
or if the underscores should be removed directly in the sqlparser crate.
   
   ### To Reproduce
   
   ```sql
   > set datafusion.sql_parser.dialect = 'postgres';
   
   > select 1_000;
   SQL error: ParserError("Cannot parse 1_000 as f64")
   ```
   
   ### Expected behavior
   
   ```sql
   postgres=# select 1_000;
    ?column?
   ----------
        1000
   ```
   
   ### Additional context
   
   _No response_


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