freshtonic opened a new pull request, #1842:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/1842

   In sqlparser PR #963 a check was introduced which limits which operators can 
be used with `ANY` and `ALL` expressions.
   
   Postgres can parse more (possibly _all_ binary operators, investigation 
pending) in this location. Postgres only seems to care that the operator yields 
a boolean - which is a semantic error, not a syntax (parse) error.
   
   Example (semantic error, not a parse error):
   
   ```
   select 123 % ANY(array[246]);
   ERROR:  op ANY/ALL (array) requires operator to yield boolean
   LINE 1: select 123 % ANY(array[246]);
                      ^
   ```
   
   The following code in `src/parser/mod.rs:2893-2908` is where the allowlist 
of operators is enforced:
   
   ```rust
   if !matches!(
       op,
       BinaryOperator::Gt
           | BinaryOperator::Lt
           | BinaryOperator::GtEq
           | BinaryOperator::LtEq
           | BinaryOperator::Eq
           | BinaryOperator::NotEq
   ) {
       return parser_err!(
           format!(
           "Expected one of [=, >, <, =>, =<, !=] as comparison operator, 
found: {op}"
       ),
           tok.span.start
       );
   };
   ```


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