iffyio commented on code in PR #1986: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1986#discussion_r2262312659
########## src/parser/mod.rs: ########## @@ -1248,6 +1248,12 @@ impl<'a> Parser<'a> { debug!("parsing expr"); let mut expr = self.parse_prefix()?; + // We would have exited early in `parse_prefix` before checking for `COLLATE`, and there's + // no infix operator handling for `COLLATE`, so we must return now. + if self.in_column_definition_state() && self.peek_keyword(Keyword::COLLATE) { + return Ok(expr); + } Review Comment: Ah that makes sense thanks for clarifying! The fix sounds reasonable and I'm thinking it could make sense to limit the special case to the [postgres precedence logic here](https://github.com/apache/datafusion-sqlparser-rs/blob/112be4eb371397e1cc56a278040ed7510107c189/src/dialect/postgresql.rs#L113C1-L114C1), if we can update the match clause with the same check if that's equivalent? ``` if w.keyword == Keyword::COLLATE && !parser.in_column_definition_state() => Some(Ok(COLLATE_PREC)) ``` -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org