Skip to content

fix(sqlengine): balance deep OR expression trees - #694

Merged
egolearner merged 4 commits into
alibaba:mainfrom
Cuiyus:fix/balance-deep-or-tree
Sep 9, 2026
Merged

fix(sqlengine): balance deep OR expression trees#694
egolearner merged 4 commits into
alibaba:mainfrom
Cuiyus:fix/balance-deep-or-tree

Conversation

@Cuiyus

@Cuiyus Cuiyus commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • consume deeply nested ANTLR OR parse trees iteratively
  • rebuild large OR runs as balanced binary trees while preserving operand order, AND boundaries, and the historical shape of small expressions
  • add a regression test for 4,096 non-foldable OR predicates and assert logarithmic tree depth

Motivation

ANTLR represents a flat OR chain as a left-deep binary tree. The parser and downstream query-analysis paths recursively traverse that shape, so sufficiently large filters can overflow the worker stack. Balancing the OR tree reduces the logic depth from O(N) to O(log N).

Validation

  • CMake configuration completed successfully
  • modified parser and regression-test translation units pass clang++ -fsyntax-only
  • repository commit/push hooks passed clang-format, Ruff, gitleaks, conventional-commit, and branch-name checks

The full query_info_test binary was not built locally because this was a cold worktree build; CI is expected to run the complete target.

@Cuiyus
Cuiyus marked this pull request as ready for review August 21, 2026 09:35
@Cuiyus
Cuiyus requested a review from zhourrr as a code owner August 21, 2026 09:35
@Cuiyus
Cuiyus requested a review from egolearner August 26, 2026 07:30

@egolearner egolearner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@egolearner
egolearner merged commit 68078e5 into alibaba:main Sep 9, 2026
30 of 31 checks passed
@Cuiyus
Cuiyus deleted the fix/balance-deep-or-tree branch September 9, 2026 06:20
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.

2 participants