wugeer commented on code in PR #1472:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1472#discussion_r1822573640


##########
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())

Review Comment:
   Because both `Hive` and `PostgreSQL` dialects support the exclamation mark, 
we check the token before the exclamation mark to determine if it's a factorial 
operator, while also avoiding the incorrect identification of Hive `BangNot` 
syntax as PostgreSQL  `PostfixFactorial`.



-- 
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

Reply via email to