Fix exception when selecting _row_number with other virtual columns by alexey-milovidov · Pull Request #100116 · ClickHouse/ClickHouse · GitHub
Skip to content

Fix exception when selecting _row_number with other virtual columns#100116

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-iceberg-virtual-columns-return
Mar 21, 2026
Merged

Fix exception when selecting _row_number with other virtual columns#100116
alexey-milovidov merged 3 commits into
masterfrom
fix-iceberg-virtual-columns-return

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Mar 19, 2026

Copy link
Copy Markdown
Member

In addRequestedFileLikeStorageVirtualsToChunk, the _row_number handling block used return instead of continue after adding the column to the chunk. This caused the function to exit the loop early, skipping any remaining virtual columns (e.g. _data_lake_snapshot_version). When a query requested both _row_number and _data_lake_snapshot_version, the chunk would have fewer columns than expected, causing an exception: "Invalid number of columns in chunk pushed to OutputPort."

Closes #87890

Changelog category (leave one):

  • Not For Changelog

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

Fix exception "Invalid number of columns in chunk" when selecting _row_number together with other virtual columns like _data_lake_snapshot_version.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.99

alexey-milovidov and others added 2 commits March 19, 2026 19:14
…uestedFileLikeStorageVirtualsToChunk`

In `addRequestedFileLikeStorageVirtualsToChunk`, the `_row_number` handling
block used `return` instead of `continue` after adding the column to the
chunk. This caused the function to exit the loop early, skipping any
remaining virtual columns (e.g. `_data_lake_snapshot_version`). When a
query requested both `_row_number` and `_data_lake_snapshot_version`, the
chunk would have fewer columns than expected, resulting in:
"Invalid number of columns in chunk pushed to OutputPort."

#87890

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_version together

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@clickhouse-gh

clickhouse-gh Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

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

clickhouse-gh Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.80% 83.80% +0.00%
Functions 24.00% 24.00% +0.00%
Branches 76.40% 76.40% +0.00%

PR changed lines: PR changed-lines coverage: 100.00% (6/6, 0 noise lines excluded)
Diff coverage report
Uncovered code

@alexey-milovidov alexey-milovidov self-assigned this Mar 19, 2026
@alexey-milovidov alexey-milovidov added pr-not-for-changelog This PR should not be mentioned in the changelog and removed pr-bugfix Pull request with bugfix, not backported by default labels Mar 21, 2026
@alexey-milovidov alexey-milovidov merged commit 563d6df into master Mar 21, 2026
162 of 163 checks passed
@alexey-milovidov alexey-milovidov deleted the fix-iceberg-virtual-columns-return branch March 21, 2026 17:36
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 21, 2026
alexey-milovidov added a commit that referenced this pull request Mar 21, 2026
…hunk`

In `addRequestedFileLikeStorageVirtualsToChunk`, the `_row_number` handling
block uses `return` instead of `continue` after adding the column to the
chunk. This causes the function to exit the loop early, skipping any
remaining virtual columns (e.g. `_data_lake_snapshot_version`). When a
query requests both `_row_number` and another virtual column after it, the
chunk has fewer columns than expected, resulting in:
"Invalid number of columns in chunk pushed to OutputPort."

The fix was originally in #100116 but was lost during merge because
#100208 (revert of #99163) had reintroduced the `return` on master
after the fix branch had already resolved it via a different code structure.

The regression test `04050_iceberg_virtual_columns_return_bug` is already
on master from #100116.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100177&sha=f10711f066fd101124e088ce33061de51ebae0e9&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29

#87890

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
arthurpassos pushed a commit to Altinity/ClickHouse that referenced this pull request May 13, 2026
…hunk`

In `addRequestedFileLikeStorageVirtualsToChunk`, the `_row_number` handling
block uses `return` instead of `continue` after adding the column to the
chunk. This causes the function to exit the loop early, skipping any
remaining virtual columns (e.g. `_data_lake_snapshot_version`). When a
query requests both `_row_number` and another virtual column after it, the
chunk has fewer columns than expected, resulting in:
"Invalid number of columns in chunk pushed to OutputPort."

The fix was originally in ClickHouse#100116 but was lost during merge because
ClickHouse#100208 (revert of ClickHouse#99163) had reintroduced the `return` on master
after the fix branch had already resolved it via a different code structure.

The regression test `04050_iceberg_virtual_columns_return_bug` is already
on master from ClickHouse#100116.

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100177&sha=f10711f066fd101124e088ce33061de51ebae0e9&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29

ClickHouse#87890

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

Labels

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.

Iceberg Logical error: Invalid number of columns in chunk

2 participants