soulstompp opened a new issue, #2809:
URL: https://github.com/apache/datafusion-sqlparser-rs/issues/2809

   version 0.63.0, `PostgreSqlDialect`.
   
   PostgreSQL's lexer reads a run of operator characters as one operator 
(manual, "Lexical Structure", "Operators"; `src/backend/parser/scan.l`). 
However, sqlparser only recognizes a specific list, so the it ends up get split.
   
   The composite type comparison operators (manual, "Composite Type 
Comparison")::
   
   ```sql
   SELECT a *= b    -- Expected: an expression, found: =
   SELECT a *<> b   -- Expected: an expression, found: <>
   SELECT a *< b    -- Expected: an expression, found: <
   SELECT a *<= b   -- Expected: an expression, found: <=
   SELECT a *> b    -- Expected: an expression, found: >
   SELECT a *>= b   -- Expected: an expression, found: >=
   ```
   
   The @@@ operator doesn't cause an error but is parsed incoretory.
   
   ```sql
   SELECT a @@@ b   -- parses as a @@ (@b); to_string() gives: SELECT a @@ @b
   `SELECT 'a b'::tsvector @@@ 'a'::tsquery;   -- t
   SELECT 'a b'::tsvector @@ @ 'a'::tsquery;  -- ERROR: operator does not exist
   ```
   
   I ran into similiar issues trying to write it as `OPERATOR()` which failed 
similiarly:
   
   ```sql
   SELECT a OPERATOR(pg_catalog.*=) b    -- Expected: ), found: =
   SELECT a OPERATOR(pg_catalog.@@@) b   -- Expected: ), found: @
   ```
   
   The `*` operators are valid on PostgreSQL 18.6, on values of a record type:
   
   ```sql
   SELECT a *= b, a = b, a *< b, a *<> b
   FROM (SELECT ROW(1.0) a, ROW(1.00) b) s;   -- f | t | f | t
   ```
   
   How to reproduce:
   
   ```rust
   use sqlparser::{dialect::PostgreSqlDialect, parser::Parser};
   for sql in ["SELECT a *= b", "SELECT a @@@ b"] {
       println!("{:?}", Parser::parse_sql(&PostgreSqlDialect {}, sql).map(|s| s
   }


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to