wugeer commented on code in PR #1472: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1472#discussion_r1822598009
########## src/parser/mod.rs: ########## @@ -2800,11 +2814,40 @@ impl<'a> Parser<'a> { format: None, }) } else if Token::ExclamationMark == tok { - // PostgreSQL factorial operation - Ok(Expr::UnaryOp { - op: UnaryOperator::PGPostfixFactorial, - expr: Box::new(expr), - }) + if self.dialect.supports_factorial_operator() { + match expr { + Expr::Value(_) | Expr::Identifier(_) | Expr::Nested(_) | Expr::BinaryOp{..} => Ok(Expr::UnaryOp { + op: UnaryOperator::PGPostfixFactorial, + expr: Box::new(expr), + }), + _ => { + self.expected( + "Value or Identifier or Nested or BinaryOp struct before factorial operator(!)", self.peek_token()) + }, + } + } else if self.dialect.supports_bang_not_operator() { Review Comment: Because both `Hive` and `PostgreSQL` dialects support the exclamation mark, we check the token after the exclamation mark to determine if it's a `BangNot` operator, while also avoiding the incorrect identification of PostgreSQL `PostfixFactorial` as Hive `BangNot` operator. -- 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