BenSatori opened a new pull request, #2490:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2490
Fixes parsing of queries like:
```sql
SELECT contact_name::text COLLATE "POSIX", * FROM customers;
```
which previously failed with `No infix parser for token Word(Word { value:
"COLLATE", ... })`.
Per [Postgres operator
precedence](https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-PRECEDENCE),
`::` binds tighter than `COLLATE`, so `PostgreSqlDialect::get_next_precedence`
already assigns `COLLATE` a (lower) precedence relative to `::`. However,
`Parser::parse_infix` had no case for the `COLLATE` keyword, so once the
precedence-driven loop reached it, parsing failed. This adds the missing
`Keyword::COLLATE` arm to build an `Expr::Collate` wrapping the already-parsed
(e.g. cast) expression.
Added a unit test (`parse_collate_after_cast`) verifying `contact_name::TEXT
COLLATE "POSIX"` parses to `Expr::Collate { expr: Expr::Cast { .. }, .. }`.
--
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]