Skip to content

perf(expression): short-circuit And/Or in boolean evaluators - #1181

Merged
wgtmac merged 1 commit into
apache:mainfrom
dino-saurabh:perf/short-circuit-boolean-evaluators
Nov 28, 2026
Merged

wgtmac merged 1 commit into
apache:mainfrom
dino-saurabh:perf/short-circuit-boolean-evaluators

Conversation

@dino-saurabh

@dino-saurabh dino-saurabh commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

The generic Visit evaluates both children of And/Or before combining them, while Java's boolean evaluators use visitEvaluator, which skips the right child when the left child decides the result.

Closes #1118.

Comment thread src/iceberg/expression/evaluator.cc Outdated
Result<bool> Evaluator::Evaluate(const StructLike& row) const {
EvalVisitor visitor(row);
return Visit<bool, EvalVisitor>(bound_expr_, visitor);
return VisitEvaluator(bound_expr_, visitor);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since #1166 merged, row evaluation runs compiled AndNode and OrNode instances. Please add short-circuiting to both nodes when rebasing, and update CompoundExpressionsKeepErrorsFromBothSides to verify that a skipped right operand is never read and a required one still propagates its error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah yes let me rebase.

Skip the right child of And/Or when the left child decides the result,
like Java's visitEvaluator. Errors from a skipped child are no longer
reported.

Closes apache#1118.
@dino-saurabh
dino-saurabh force-pushed the perf/short-circuit-boolean-evaluators branch from eae7520 to 29d5716 Compare November 27, 2026 06:27
@dino-saurabh
dino-saurabh requested a review from wgtmac November 27, 2026 06:40

@zhjwpku zhjwpku left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1

@wgtmac wgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @dino-saurabh for working on this and @zhjwpku for the review!

@wgtmac
wgtmac merged commit f367f75 into apache:main Nov 28, 2026
15 checks passed
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.

Boolean expression evaluators don't short-circuit AND/OR

3 participants