iffyio commented on code in PR #2157:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2157#discussion_r2716560841
##########
src/parser/mod.rs:
##########
@@ -1856,6 +1856,21 @@ impl<'a> Parser<'a> {
chain.push(AccessExpr::Dot(expr));
self.advance_token(); // The consumed string
}
+ // Handle words (including keywords like INTERVAL) as
identifiers
Review Comment:
Can we instead of having a new clause (which duplicates some edge cases), we
can extend the catch all branch to be more strict around what we're expecting.
I think that makes it easier to detect if we were supposed to parse the
expression as an identifier. e.g.
```rust
// Fallback ...
_ => {
// Parse any of the suffix expressions we expect to follow the dot
operator.
let expr = self.maybe_parser(|parser| {
let expr = parser.parse_subexpr()?;
if matches!(
expr,
CompoundFieldAccess {...} |
CompoundIdentifier(_) |
Identifier(_) |
Value |
Function {..}
) {
Some(expr)
}
});
match expr {
// As usual
Some(CompoundFieldAccess{..}) => {..}
Some(CompoundIdentifier(_)) => {...}
Some(expr) => {...}
// If its not a suffix we expect, accept only if its an
identifier.
None => {
chain.push(AccessExpr::Dot(Expr::Identifier(self.parse_identifier()?)));
}
}
}
```
--
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]