Skip to content

Parser: optionally charge infix operator chains to the recursion limit - #3057

Open
moshap-firebolt wants to merge 1 commit into
apache:mainfrom
firebolt-analytics:moshap/upstream-infix-chain-depth
Open

moshap-firebolt wants to merge 1 commit into
apache:mainfrom
firebolt-analytics:moshap/upstream-infix-chain-depth

Conversation

@moshap-firebolt

Copy link
Copy Markdown
Contributor

parse_subexpr parses a chain such as 1 + 1 + ... + 1 in a loop, so the whole chain costs one level of the recursion limit, yet the resulting Expr nests one level per operator. Dropping or serializing it recurses that deep: a million-term chain overflows a 64 MiB stack in serde's Serialize.

Parser::with_infix_chain_depth(true) charges each operator of the chain to the recursion counter, so the limit bounds the depth of the tree that is built. It is off by default, since visitor::tests::overflow expects a 1,000-term OR chain to parse under the default limit of 50.

Test: parse_infix_chain_with_chain_depth_hits_recursion_limits.

This PR was prepared with AI assistance (Claude).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

No dialect label was applied because the title does not name a SQL dialect.

If this change targets one or more dialects, edit the title to <Dialect>[, <Dialect>]: <description>, add a Dialects: <Dialect>[, <Dialect>] line to the description, or reply with one. Reply Dialects: none if the change is dialect-agnostic.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.57%. Comparing base (323a60e) to head (9967d39).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3057   +/-   ##
=======================================
  Coverage   83.57%   83.57%           
=======================================
  Files          42       42           
  Lines       35719    35724    +5     
  Branches    35719    35724    +5     
=======================================
+ Hits        29853    29858    +5     
  Misses       2425     2425           
  Partials     3441     3441           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaCappelletti94

Copy link
Copy Markdown
Contributor

What is the reason for having this optional?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants