Skip to content

Add test: fieldToNumber<bool> out-of-range Float64 branch in SettingsFields.cpp untested - #104476

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr104154
May 9, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr104154

Conversation

@clickgapai

Copy link
Copy Markdown
Contributor

Found via ClickGap automated review. Please close or comment if this is incorrect or needs adjustment.

This is a test-only PR — no source code changes. Please review: test quality, whether the claimed coverage gaps are real, and whether test output makes sense.

Adds test coverage for 1 untested code path(s), found during automated review of PR #104154.
That PR This PR fixes undefined behavior in FieldVisitorConvertToNumber<T>::operator()(Float64) and fieldToNumber<T> for wide integer types (UInt64, Int64, Int128, etc.) when the input Float64 is at the 2^64 boundary. The old code used x > Float64(numeric_limits<T>::max()) which failed for wide intege

1. fieldToNumber<bool> out-of-range Float64 branch in SettingsFields.cpp untested
src/Core/SettingsFields.cpp:129
Risk: fieldToNumber<bool> at SettingsFields.cpp:127-130 branches on std::is_same_v<T, bool> to use naive comparison instead of accurate::lessOp (which won't compile for bool). Call chain: `SettingFiel
What's unique vs PR tests: PR's test 04205_field_visitor_convert_to_number_ubsan_103817.sql tests the UInt64 boundary (1.8446744073709552e19) for aggregate functions and settings. My test covers the BOOL special case branch whi
Try it on ClickHouse Fiddle

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

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

Not applicable — test-only change.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@clickgapai
clickgapai force-pushed the qa-bot/coverage-pr104154 branch from 72e43fa to 1efee1d Compare May 9, 2026 18:25
@groeneai

groeneai commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Reviewed this PR — it fills a real coverage gap from #104154. Approving.

Coverage gap verification: Legitimate. The merged #104154 added an if constexpr (std::is_same_v<T, bool>) branch to fieldToNumber<T> in src/Core/SettingsFields.cpp (lines 122–126 on master) that uses naive Float64 comparison instead of accurate::greaterOp / accurate::lessOp (since make_unsigned_t<bool> is ill-formed). The existing test 04205_field_visitor_convert_to_number_ubsan_103817.sql exercises only the wide-integer side via topK(...) parameters and SET max_threads = ... / SET max_block_size = ... — both UInt64 paths. The new test is the first to drive the bool branch.

Test logic verification: All cases trace through fieldToNumber<bool> → Field::Types::Float64 branch → if constexpr (std::is_same_v<T, bool>) (the special-case branch). Verified locally against 26.5.1.1 debug build:

Query Path Result
SET enable_analyzer = 1.5 1.5 > Float64(1) = max<bool> throws CANNOT_CONVERT_TYPE ✓
SET enable_analyzer = 2.0 2.0 > Float64(1) throws ✓
SET enable_analyzer = -0.5 -0.5 < Float64(0) = lowest<bool> throws ✓
SET enable_analyzer = -1.0 -1.0 < Float64(0) throws ✓
SET enable_analyzer = 1.0 in range, T(1.0) = true true ✓
SET enable_analyzer = 0.0 in range, T(0.0) = false false ✓
SET enable_analyzer = 0.5 in range, T(0.5) = true (non-zero) true ✓
SET enable_analyzer = 0.999 in range, T(0.999) = true (non-zero) true ✓

enable_analyzer is confirmed Bool (alias of allow_experimental_analyzer declared in src/Core/Settings.cpp:7367), so the test does exercise fieldToNumber<bool>.

Local repro: tests/clickhouse-test 04212_settings_bool_out_of_range_float --test-runs 10 → 10/10 passed under default random settings + random MergeTree settings on debug build.

Nits (non-blocking):

  1. Test number 04212_ skips 04211_ (highest existing on master is 04210_, so the conventional add-test script would have assigned 04211_). No conflict since neither number is in use, but mentioning in case it matters to maintainers.
  2. The header comment references SettingsFields.cpp:129-130 — after the merge of Fix UBSan in FieldVisitorConvertToNumber for wide-integer Float64 boundary #104154 the bool branch is at lines 122–126. Tiny correction, not worth a re-push.

Label: I'd add can be tested myself but I'm a fork contributor — that label requires a maintainer. cc @alexey-milovidov — could you flip the label so this can run CI?

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label May 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [1efee1d]

Summary: ✅


AI Review

Summary

This PR adds a focused stateless SQL test for the fieldToNumber<bool> out-of-range Float64 path in SettingsFields.cpp. The change is test-only, targets a real branch, and the expected output/exception checks are consistent with current conversion behavior.

ClickHouse Rules
Item Status Notes
Deletion logging ➖
Serialization versioning ➖
Core-area scrutiny ✅
No test removal ✅
Experimental gate ➖
No magic constants ✅
Backward compatibility ✅
SettingsChangesHistory.cpp ➖
PR metadata quality ✅
Safe rollout ➖
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label May 9, 2026

@alexey-milovidov alexey-milovidov 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.

Weird.

@alexey-milovidov alexey-milovidov self-assigned this May 9, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue May 9, 2026
Merged via the queue into ClickHouse:master with commit f55ff96 May 9, 2026
165 checks passed
@robot-ch-test-poll1 robot-ch-test-poll1 added the pr-synced-to-cloud The PR is synced to the cloud repo label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants