Repository navigation
Parser: fix exponential parse time on (x) -> lambda chains - #2699
Open
moshap-firebolt wants to merge 2 commits into
Open
moshap-firebolt wants to merge 2 commits into
moshap-firebolt wants to merge 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
moshap-firebolt
force-pushed
the
lambda-exponential
branch
from
October 22, 2026 04:06
be348bb to
451fc78
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2699 +/- ##
=======================================
Coverage 81.53% 81.53%
=======================================
Files 42 42
Lines 34218 34228 +10
Branches 34218 34228 +10
=======================================
+ Hits 27898 27908 +10
Misses 2770 2770
Partials 3550 3550 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
try_parse_lambdaspeculatively 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:This affects every dialect whose
supports_lambda_functions()is true: ClickHouse, Snowflake, DuckDB, Spark and Databricks. On each of them, release build, main3330dc9e: 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
ParserStateas 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 withsupports_lambda_functions().This PR was prepared with AI assistance (Claude).
Dialects: ClickHouse, Snowflake, DuckDB, Spark, Databricks
🤖 Generated with Claude Code