moshap-firebolt opened a new pull request, #2699: URL: https://github.com/apache/datafusion-sqlparser-rs/pull/2699
`try_parse_lambda` speculatively parses `(<params>) -> <body>`. When the body fails, the fallback parses `(x)` as a nested expression and `->` as a binary operator, whose right operand starts the same speculative parse again. A chain of lambdas whose last body is incomplete therefore doubles the work per level: ```sql SELECT (x) -> (x) -> (x) -> ... 1 + ``` This affects every dialect whose `supports_lambda_functions()` is true: ClickHouse, Snowflake, DuckDB, Spark and Databricks. On each of them, release build, main `3330dc9e`: 20 levels (110 bytes) take 1.4 s, 24 levels (130 bytes) take 23 s. With this change 24 levels take under 0.5 ms and 40 levels about 1 ms. The fix caches where the lambda arm failed, keyed by position and `ParserState` as in #2619. Valid SQL never reaches the cache; only a chain that already failed retries it. Tests: a timeout regression at 24 levels, which fails without the change, and the lambda and `->` fallback forms, including a chain whose inner lambda is answered from the cache. Both run on every dialect with `supports_lambda_functions()`. This PR was prepared with AI assistance (Claude). Dialects: ClickHouse, Snowflake, DuckDB, Spark, Databricks 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
