Skip to content

Add test: Flattened xxxMap inside a Tuple whose key array is in the sorting key is excluded from summation — break at SummingSortedAlgorithm.cpp:495 untested - #107193

Merged
nihalzp merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr98039
Jun 11, 2026
Merged

nihalzp merged 1 commit into
ClickHouse:masterfrom
clickgapai:qa-bot/coverage-pr98039

Conversation

@clickgapai

@clickgapai clickgapai commented Jun 11, 2026 •

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 #98039.
That PR Adds immutable MergeTree setting allow_tuple_element_aggregation (default off). When enabled, SummingMergeTree/AggregatingMergeTree/CoalescingMergeTree recursively flatten Tuple columns via new Nested::flattenTupleRecursive/reconstructTupleColumnsRecursive helpers and aggregate each le

1. Flattened xxxMap inside a Tuple whose key array is in the sorting key is excluded from summation — break at SummingSortedAlgorithm.cpp:495 untested
src/Processors/Merges/Algorithms/SummingSortedAlgorithm.cpp:495
Risk: defineColumns discovers the flattened leaves metrics.ratesMap.ID/metrics.ratesMap.Value as a real sumMap, then the map loop at SummingSortedAlgorithm.cpp:491-495 checks whether any map column is in the sorting/partition key and, if so, breaks to push the whole map into column_numbers_not_to_aggregate. RISK: if this exclusion is broken/inverted, a map keyed by a sort-key column would be silently merged by key, producing wrong aggregated results and potential sort-order violations …
What's unique vs PR tests: PR Test 9 (03802_summing_merge_tree_tuple_element.sql) covers a flattened map with ORDER BY id where the map IS summed. No PR test places the flattened map's key leaf in the sorting key, so the map-exclusion break at line 495 is never exercised by the PR's own tests.
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)

Version info

  • Merged into: 26.6.1.670

@clickgapai

Copy link
Copy Markdown
Contributor Author

Pre-PR Validation Gate (per ClickGap pipeline):

a) Deterministic repro? ✅
Test exercises the previously-uncovered branch and passes (correct behaviour).

b) Root cause explained? ✅
src/Processors/Merges/Algorithms/SummingSortedAlgorithm.cpp:493-495: the isInSortingKey(...) || isColumnOrAncestorInNames(...) check followed by break for a discovered map — correct but uncovered (LLVM marks line 495 break uncovered).

c) Fix matches root cause? ✅
N/A for coverage gap — this PR adds a regression test, not a fix. Asserts current correct behaviour at the cited line.

d) Test intent preserved? / New tests added? ✅
New regression test added: 04335_summing_merge_tree_tuple_map_in_sorting_key.sql.

e) Both directions demonstrated? ✅
Test passes (MATCH) on master proving current correctness; would fail if the cited branch regressed. Single-direction is the correct shape for a coverage gap test.

f) Fix is general, not a narrow patch? ✅
Test asserts the invariant at the cited line — covers the branch, not a specific input shape.

@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e7e1d45]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, parallel, 1/2) FAIL
00061_storage_buffer FAIL cidb, issue ISSUE CREATED

AI Review

Summary

This test-only PR adds a stateless regression test for SummingMergeTree with allow_tuple_element_aggregation, verifying that a flattened xxxMap inside a Tuple is not summed when one of the map leaf columns is part of the sorting key. I found no correctness issue in the added test; the contrast table makes the intended branch behavior observable.

Missing context / blind spots
  • ⚠️ I could not run the new stateless test locally because this checkout has no build* directory or ClickHouse binary. The fetched Praktika report for commit e7e1d4573cf3355d6f95edd7039e82df99b29a3e showed Config Workflow and Style check passed, with stateless test jobs still pending; a completed stateless run would close this gap.
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 Jun 11, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.70% 84.60% -0.10%
Functions 92.30% 92.30% +0.00%
Branches 77.30% 77.30% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 313 line(s), 18 function(s) across 108 file(s) · Details

Top files
  • src/Backups/BackupCoordinationStageSync.cpp: 15 line(s)
  • src/AggregateFunctions/AggregateFunctionQuantileGK.cpp: 14 line(s)
  • src/Storages/ObjectStorageQueue/ObjectStorageQueueSource.cpp: 14 line(s)
  • src/Databases/DatabaseFactory.cpp: 11 line(s)
  • src/Storages/ObjectStorageQueue/ObjectStorageQueueUnorderedFileMetadata.cpp: 10 line(s), 1 function(s)

Full report

@nihalzp
nihalzp added this pull request to the merge queue Jun 11, 2026
Merged via the queue into ClickHouse:master with commit f844890 Jun 11, 2026
164 of 166 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 11, 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.

3 participants