Skip to content

Do not emit a GROUP BY group out of a zero-row block - #117503

Merged
fm4v merged 9 commits into
masterfrom
yarik/fix-group-by-zero-row-block
Sep 2, 2026
Merged

fm4v merged 9 commits into
masterfrom
yarik/fix-group-by-zero-row-block

Conversation

@yariks5s

@yariks5s yariks5s commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixes a case where GROUP BY emits a group from a zero-row block, returning a row with count() = 0. Closes #116830.


Workflow [PR]
Sync PR [sync-upstream/pr/117503]

Version info

  • Merged into: 26.9.1.563 (included in 26.9 and later)
  • Backported to: 26.8.3.58, 26.7.7.43, 26.6.5.69

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


yariks5s seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e917700]

Summary: ❌

job_name test_name status info comment
LLVM Coverage FAIL
Generate LLVM Coverage Diff Report FAIL cidb
Print Uncovered Code FAIL cidb Uncovered code analysis did not run: bash ci/jobs/scripts/generate_diff_coverage_report.sh failed (its output is on the Generate LLVM Coverage Diff Report result).
Parser memory check ERROR
Resolve master binary ERROR

AI Review

Summary

This PR fixes the zero-row GROUP BY fast path in Aggregator so runtime-constant keys no longer synthesize a phantom group, and it adds focused regressions for the default path plus the old -Array UBSan reproducer. The executor change itself looks correct, but one user-visible compatibility distinction from the resolved review thread is still not pinned by tests.

Tests
  • ⚠️ Add a runtime-constant case to 05055_group_by_zero_row_block.sql with empty_result_for_aggregation_by_constant_keys_on_empty_set = 0 expecting an empty result. 01925_test_group_by_const_consistency covers only the planner-eliminated literal-key case; without this, the deliberate distinction that runtime ColumnConst keys ignore that setting can regress silently.
Final Verdict
  • Status: ⚠️ Request changes
  • Add the empty_result_for_aggregation_by_constant_keys_on_empty_set = 0 runtime-constant regression to 05055_group_by_zero_row_block.sql.

LLVM Coverage Report

⚠️ No coverage measurement for commit e917700: bash ci/jobs/scripts/generate_diff_coverage_report.sh failed (its output is on the Generate LLVM Coverage Diff Report result).

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Sep 1, 2026
Comment thread src/Interpreters/Aggregator.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing e917700a2 with master bb3c0a852 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

13 translation units recompiled, 88 s compile time in total, 13 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.07 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +6.4 s (+8%) in total before that adjustment.

Job report

@fm4v
fm4v enabled auto-merge September 2, 2026 19:39
@fm4v
fm4v added this pull request to the merge queue Sep 2, 2026
Merged via the queue into master with commit cf0b103 Sep 2, 2026
171 of 175 checks passed
@fm4v
fm4v deleted the yarik/fix-group-by-zero-row-block branch September 2, 2026 20:17
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Sep 2, 2026
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Sep 2, 2026
robot-ch-test-poll added a commit that referenced this pull request Sep 7, 2026
Cherry pick #117503 to 26.6: Do not emit a GROUP BY group out of a zero-row block
robot-clickhouse added a commit that referenced this pull request Sep 7, 2026
robot-ch-test-poll added a commit that referenced this pull request Sep 7, 2026
Cherry pick #117503 to 26.7: Do not emit a GROUP BY group out of a zero-row block
robot-clickhouse added a commit that referenced this pull request Sep 7, 2026
robot-clickhouse added a commit that referenced this pull request Sep 7, 2026
robot-ch-test-poll added a commit that referenced this pull request Sep 7, 2026
Cherry pick #117503 to 26.8: Do not emit a GROUP BY group out of a zero-row block
robot-clickhouse added a commit that referenced this pull request Sep 7, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 7, 2026
clickhouse-gh Bot added a commit that referenced this pull request Sep 7, 2026
Backport #117503 to 26.6: Do not emit a GROUP BY group out of a zero-row block
clickhouse-gh Bot added a commit that referenced this pull request Sep 7, 2026
Backport #117503 to 26.8: Do not emit a GROUP BY group out of a zero-row block
clickhouse-gh Bot added a commit that referenced this pull request Sep 7, 2026
Backport #117503 to 26.7: Do not emit a GROUP BY group out of a zero-row block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GROUP BY emits a group from a zero-row block, returning a row with count() = 0

7 participants