This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new ab8991a140 Support uint64 literals (#6146)
ab8991a140 is described below

commit ab8991a140139e0ad53b942d0673ebabc0e9fcc3
Author: Jack Kleeman <[email protected]>
AuthorDate: Sun Apr 30 15:25:35 2023 +0100

    Support uint64 literals (#6146)
    
    * Support uint64 literals
    
    It should be possible to compare numeric types to uint64 literals. 
Currently for anything above the int64 max, it will become a float or a 
decimal128 depending on config. The float conversion is lossy, and the decimal 
type is currently not comparable with uint64, so both of these are problematic.
    
    * fix: fmt
    
    ---------
    
    Co-authored-by: Andrew Lamb <[email protected]>
---
 datafusion/sql/src/expr/value.rs         | 2 ++
 datafusion/sql/tests/integration_test.rs | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/datafusion/sql/src/expr/value.rs b/datafusion/sql/src/expr/value.rs
index df9e44be3f..f1c93d8bdc 100644
--- a/datafusion/sql/src/expr/value.rs
+++ b/datafusion/sql/src/expr/value.rs
@@ -49,6 +49,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
     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');
diff --git a/datafusion/sql/tests/integration_test.rs 
b/datafusion/sql/tests/integration_test.rs
index 64ca85b72d..a69a824a3e 100644
--- a/datafusion/sql/tests/integration_test.rs
+++ b/datafusion/sql/tests/integration_test.rs
@@ -56,6 +56,11 @@ fn parse_decimals() {
             "10000000000000000000.00",
             "Decimal128(Some(1000000000000000000000),22,2)",
         ),
+        ("18446744073709551615", "UInt64(18446744073709551615)"),
+        (
+            "18446744073709551616",
+            "Decimal128(Some(18446744073709551616),38,0)",
+        ),
     ];
     for (a, b) in test_data {
         let sql = format!("SELECT {a}");

Reply via email to