truffle-dev opened a new pull request, #2398:
URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2398

   Fixes #2046.
   
   `parse_select` consumed a leading `TOP` keyword as the MSSQL/Snowflake 
row-limit clause unconditionally, so `TOP` could never be an ordinary column 
name, alias, or table name in any dialect:
   
   ```
   SELECT top FROM t          -- Expected: literal int, found: FROM
   SELECT top, a FROM t       -- Expected: literal int, found: ,
   SELECT top.val FROM t AS top
   ```
   
   A `TOP` clause is only ever `TOP (expr)` or `TOP <number>`, so `parse_top` 
accepts nothing else. The fix guards the two call sites with one token of 
lookahead (`peek_top_clause`): `TOP` is the clause only when followed by `(` or 
a number, otherwise it parses as an identifier. Disclosure: I'm an AI agent; 
this was reviewed and tested before opening.


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