Skip to content

Fix exception when selecting _row_number with other virtual columns - #100295

Merged
alexey-milovidov merged 2 commits into
masterfrom
fix-iceberg-virtual-columns-return-lost
Mar 22, 2026
Merged

alexey-milovidov merged 2 commits into
masterfrom
fix-iceberg-virtual-columns-return-lost

Conversation

@alexey-milovidov

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

Copy link
Copy Markdown
Member

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, 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.

CI report: 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
#100177

#87890

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

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

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

  • Merged into: 26.4.1.114

@clickhouse-gh

clickhouse-gh Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e4d3dba]

Summary: ✅


AI Review

Summary

This PR fixes a real regression in addRequestedFileLikeStorageVirtualsToChunk: replacing return with continue in the _row_number branch so subsequent requested virtual columns are still appended to the Chunk. The change is minimal, directly addresses the reported exception, and is covered by a dedicated stateless regression test that reproduces the multi-virtual-column scenario.

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 ✅

Final Verdict

  • Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Mar 21, 2026
alexey-milovidov and others added 2 commits March 21, 2026 20:06
…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) <[email protected]>
@alexey-milovidov
alexey-milovidov force-pushed the fix-iceberg-virtual-columns-return-lost branch from 2a3aebc to e4d3dba Compare March 21, 2026 19:07
@clickhouse-gh

clickhouse-gh Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 83.90% 83.80% -0.10%
Functions 24.60% 24.70% +0.10%
Branches 76.50% 76.50% +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 22, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Mar 22, 2026
Merged via the queue into master with commit 216b60a Mar 22, 2026
294 of 296 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-iceberg-virtual-columns-return-lost branch March 22, 2026 09:47
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Mar 22, 2026
il9ue pushed a commit to Altinity/ClickHouse that referenced this pull request May 26, 2026
The path resolution refactor in ClickHouse#100420/ClickHouse#100295 changed `FileNamesGenerator`'s
constructor signature (5 args → 4 args, with `is_transactional` mapped to
`use_uuid_in_metadata` and `config_path` removed) and removed
`generateMetadataName()` in favour of `generateMetadataPathWithInfo()`.
The `generateManifestList` signature also changed: first arg is now
`IcebergPathResolver` instead of `FileNamesGenerator`, and manifest entry
sizes is `std::vector<Int64>` instead of a scalar.

Adapt the `TRUNCATE TABLE` code path (from #1655) to the new API:

- Two-branch `FileNamesGenerator` construction (transactional vs. non-transactional,
  reading location from JSON) → single construction using
  `persistent_components.path_resolver.getTableLocation()` with
  `is_transactional` as `use_uuid_in_metadata`.
- `generateMetadataName()` → `generateMetadataPathWithInfo()`, returning
  `GeneratedMetadataFileWithInfo { path, version, compression_method }`.
- Storage paths derived via `path_resolver.resolve(path)` where raw strings
  were previously returned.
- Catalog filename via `path_resolver.resolveForCatalog(path)`, replacing the
  manual `location + metadata_name` concatenation.
- `generateManifestList(filename_generator, ...)` → `generateManifestList(path_resolver, ...)`.

Behavior of truncate is preserved: clears data files by writing a new
snapshot with empty manifests and updates the catalog pointer. The new
`IcebergPathResolver` abstraction handles both transactional (full URI)
and non-transactional (bare path) cases transparently.

Refs: #1785, #1655
zvonand added a commit to Altinity/ClickHouse that referenced this pull request Jun 1, 2026
…100420

Backport of ClickHouse#100420/ClickHouse#100295 - Resolve problems with paths and compatibility problems with Spark in Azure (v2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci 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.

2 participants