Skip to content

Round Float64 results in test 02931_rewrite_sum_column_and_constant - #100410

Closed
alexey-milovidov wants to merge 4 commits into
masterfrom
fix-02931-float-rounding-master
Closed

alexey-milovidov wants to merge 4 commits into
masterfrom
fix-02931-float-rounding-master

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 23, 2026 •

Copy link
Copy Markdown
Member

Test 02931_rewrite_sum_column_and_constant fails under TSan with random settings due to floating-point precision differences. When optimize_arithmetic_operations_in_aggregate_functions is disabled, sum(2.11 - uint64) produces -4.45 instead of -4.450000000000001. Both are valid results for the same mathematical value. Wrap Float64 arithmetic queries with round(..., 2) to avoid flaky results.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98677&sha=c1d06924bbc951a62ad4a320efdcb22722d72d4b&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29
#98677

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

The test fails with TSan due to floating-point precision differences
when random settings change the evaluation order of sum(constant - column).
Wrap Float64 arithmetic queries with `round(..., 2)` to avoid flaky results.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98677&sha=c1d06924bbc951a62ad4a320efdcb22722d72d4b&name_0=PR&name_1=Stateless%20tests%20%28amd_tsan%2C%20parallel%2C%202%2F2%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e4523df]

Summary: ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adjusts a stateless regression test to be robust against benign Float64 rounding differences that appear under TSan + random settings when optimize_arithmetic_operations_in_aggregate_functions is toggled, preventing flaky expected output mismatches.

Changes:

  • Wraps several sum(... Float64 ...) result queries with round(..., 2) in 02931_rewrite_sum_column_and_constant.sql.
  • Updates the corresponding .reference expected outputs to match the rounded results.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/queries/0_stateless/02931_rewrite_sum_column_and_constant.sql Rounds Float64 aggregate results to avoid precision-dependent golden output.
tests/queries/0_stateless/02931_rewrite_sum_column_and_constant.reference Updates expected output values to the rounded form.

alexey-milovidov and others added 3 commits March 23, 2026 12:16
Master commit bee37fa already fixed the flaky test by changing
the constant from `2.11` to `2.125`, which is exactly representable
in binary floating-point. This makes the `round()` wrapping unnecessary.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants