Skip to content

Commit ab8991a

Browse files
jackkleemanalamb
andauthored
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]>
1 parent 2f39479 commit ab8991a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

datafusion/sql/src/expr/value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
4949
fn parse_sql_number(&self, n: &str) -> Result<Expr> {
5050
if let Ok(n) = n.parse::<i64>() {
5151
Ok(lit(n))
52+
} else if let Ok(n) = n.parse::<u64>() {
53+
Ok(lit(n))
5254
} else if self.options.parse_float_as_decimal {
5355
// remove leading zeroes
5456
let str = n.trim_start_matches('0');

datafusion/sql/tests/integration_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ fn parse_decimals() {
5656
"10000000000000000000.00",
5757
"Decimal128(Some(1000000000000000000000),22,2)",
5858
),
59+
("18446744073709551615", "UInt64(18446744073709551615)"),
60+
(
61+
"18446744073709551616",
62+
"Decimal128(Some(18446744073709551616),38,0)",
63+
),
5964
];
6065
for (a, b) in test_data {
6166
let sql = format!("SELECT {a}");

0 commit comments

Comments
 (0)