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


##########
src/parser/mod.rs:
##########
@@ -2799,12 +2806,33 @@ impl<'a> Parser<'a> {
                 data_type: self.parse_data_type()?,
                 format: None,
             })
-        } else if Token::ExclamationMark == tok {
-            // PostgreSQL factorial operation
+        } else if Token::ExclamationMark == tok && 
self.dialect.supports_factorial_operator() {
             Ok(Expr::UnaryOp {
                 op: UnaryOperator::PGPostfixFactorial,
                 expr: Box::new(expr),
             })
+        } else if Token::ExclamationMark == tok && 
self.dialect.supports_bang_not_operator() {
+            let token = self.next_token();
+            match token.token {
+                Token::Word(_) | Token::Number(..)
+                    if !matches!(
+                        expr,
+                        Expr::Value(_)
+                            | Expr::Identifier(_)
+                            | Expr::Nested(_)
+                            | Expr::BinaryOp { .. }
+                    ) =>
+                {
+                    Ok(Expr::UnaryOp {
+                        op: UnaryOperator::BangNot,
+                        expr: Box::new(expr),
+                    })
+                }
+                _ => parser_err!(
+                    "current dialect support bang not operator, but with wrong 
syntax",
+                    tok.location
+                ),

Review Comment:
   @iffyio  Let’s remove  this complex context validation logic in this part 
for now to keep the original logic simple. I've pushed the updated code. Thank 
you for review! :)



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