mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-11 14:32:04 +00:00
Implement Hash on all AST nodes
It is convenient for downstream libraries to be able to stash bits of ASTs into hash maps, e.g., for performing simple common subexpression elimination. The only downside to this change is that it requires that the f64 in the Value enum be wrapped in an OrderedFloat, which provides the necessary equality semantics to allow Hash to be drived. The reason f64 doesn't implement Hash by default is because NaN is typically not equal to itself, so it's not clear what it should hash to. That's less of a concern in a SQL context, because every SQL database I've looked at treats NaN as equal to itself, in violation of the IEEE standard, in order to permit indexing and sorting of float columns.
This commit is contained in:
parent
a3aaa49a7e
commit
c49352f394
8 changed files with 34 additions and 31 deletions
|
@ -1022,7 +1022,7 @@ impl Parser {
|
|||
}
|
||||
},
|
||||
Token::Number(ref n) if n.contains('.') => match n.parse::<f64>() {
|
||||
Ok(n) => Ok(Value::Double(n)),
|
||||
Ok(n) => Ok(Value::Double(n.into())),
|
||||
Err(e) => parser_err!(format!("Could not parse '{}' as f64: {}", n, e)),
|
||||
},
|
||||
Token::Number(ref n) => match n.parse::<u64>() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue