Skip to content

Fix exception when ORDER BY WITH FILL is used with LIMIT BY - #98361

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-with-fill-limit-by
Mar 1, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-with-fill-limit-by

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

Summary

  • Fix "Filling column ... is not present in the block" exception when ORDER BY ... WITH FILL is combined with LIMIT BY
  • The ActionsChain optimization removed ORDER BY columns from the before_limit_by_actions step output, but they are required by the FillingStep added later
  • Preserve ORDER BY columns in the LIMIT BY expression step when WITH FILL is used, similar to how they are already preserved for distributed query processing

Closes #84427

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98291&sha=18aa50a0669a66282b7596ca1393799490f8aeb2&name_0=PR&name_1=BuzzHouse%20%28amd_tsan%29
#98291

Test plan

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):

Fix exception when ORDER BY ... WITH FILL is used together with LIMIT BY.

🤖 Generated with Claude Code

Version info

  • Merged into: 26.3.1.230

When both `ORDER BY ... WITH FILL` and `LIMIT BY` are used together,
the `ActionsChain` optimization removes ORDER BY columns from the
`before_limit_by_actions` step output because they appear unused by
subsequent analysis steps. However, the `FillingStep` (added later
during plan construction) requires these columns in the block header,
causing a "Filling column ... is not present in the block" exception.

The fix preserves ORDER BY columns in the LIMIT BY expression step
when `WITH FILL` is used, similar to how they are already preserved
for distributed query processing.

Closes #84427

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=98291&sha=18aa50a0669a66282b7596ca1393799490f8aeb2&name_0=PR&name_1=BuzzHouse%20%28amd_tsan%29

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Mar 1, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3b164e8]

Summary: ❌

job_name test_name status info comment
Performance Comparison (amd_release, master_head, 2/6) failure
Select historical data failure
Performance Comparison (amd_release, master_head, 6/6) failure
Select historical data failure

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Mar 1, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Perfect!

@alexey-milovidov alexey-milovidov self-assigned this Mar 1, 2026
@alexey-milovidov
alexey-milovidov merged commit f0d4284 into master Mar 1, 2026
142 of 144 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-with-fill-limit-by branch March 1, 2026 23:41
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 1, 2026
@PedroTadim PedroTadim mentioned this pull request Mar 2, 2026
1 task
@clickgapai

Copy link
Copy Markdown
Contributor

Hi @alexey-milovidov — while reviewing this PR I found the following:

Happy to discuss — close anything that's wrong or already addressed.

@clickgapai

Copy link
Copy Markdown
Contributor

Apologies for the duplicate notification — we had a race condition in our notification system where multiple processes posted simultaneously. The duplicate has been removed and we've added a strict 3-layer dedup guard (DB lock + immediate key + GitHub comment check) to ensure this cannot happen again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

Logical error: 'Filling column rank() OVER () is not present in the block 1_UInt8'

3 participants