fmcmac opened a new pull request, #2619: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2619
`parse_position_expr` first tries `POSITION(<expr> IN <expr>)`. When that fails it falls back to an ordinary function call, which parses the same argument again. Nested calls without `IN` therefore double the work per level: ```sql SELECT POSITION(POSITION(POSITION( ... 1 ... ))) ``` On `GenericDialect`, release build: 20 levels (208 bytes) take 1.3 s, 24 levels (248 bytes) take 21 s. With this change 40 levels take under 1 ms. The fix caches where the `IN` form failed, as #2352 and #2372 do. The key includes `ParserState`, because `PRIOR` is an operator inside `CONNECT BY` and a name elsewhere, and `parse_in` can reach one span in both. `maybe_parse` keeps `RecursionLimitExceeded` fatal, so only syntax failures are cached. Tests: a timeout regression at 24 levels, the `IN` and fallback forms nested in each other, and a `CONNECT BY` list that reparses across states. The timeout and `CONNECT BY` tests each fail with their part of the change removed. A differential over 204 statements on 13 dialects showed no change in output or errors. This PR was prepared with AI assistance (Claude), and reviewed independently by a second model before submission. -- 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]
