Skip to content

Adjust case_when DivideByZeroProtection benchmark so that "percentage of zeroes" corresponds to "number of times protection is needed"#20105

Merged
alamb merged 2 commits intoapache:mainfrom
pepijnve:div_zero_bench
Feb 2, 2026
Merged

Adjust case_when DivideByZeroProtection benchmark so that "percentage of zeroes" corresponds to "number of times protection is needed"#20105
alamb merged 2 commits intoapache:mainfrom
pepijnve:div_zero_bench

Conversation

@pepijnve
Copy link
Contributor

@pepijnve pepijnve commented Feb 2, 2026

Which issue does this PR close?

Rationale for this change

The case_when microbenchmark that covers the pattern CASE WHEN d != 0 THEN n / d ELSE NULL END pattern is parameterised over the percentage of zeroes in the d column. The benchmark uses the condition d > 0 rather than d != 0 though which is a bit misleading. In the '0% zeroes' run one would expect the else branch to never be taken, but because slightly less than 50% of the d values is negative, it's still taken 50% of the time.

This PR adjust the benchmark to use d != 0 instead.

What changes are included in this PR?

  • Adjust the divide by zero benchmark to use d != 0 as condition
  • Remove the duplicate benchmark, the div-by-zero variant is sufficient to compare changes across branches
  • Add a couple of SLTs to cover the CASE pattern

Are these changes tested?

Manual testing

Are there any user-facing changes?

No

@github-actions github-actions bot added physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt) labels Feb 2, 2026
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Makes sense to me -- thank you @pepijnve

fyi @CuteChuanChuan

@alamb
Copy link
Contributor

alamb commented Feb 2, 2026

Merging this in so I can re-run the benchmarks on #19994

Merged via the queue into apache:main with commit d28a03c Feb 2, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

physical-expr Changes to the physical-expr crates sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants