Skip to content

Native Common Virtuals for File-Like - #101409

Merged
Michicosun merged 2 commits into
masterfrom
native_common_virtuals/FileLike
Apr 1, 2026
Merged

Michicosun merged 2 commits into
masterfrom
native_common_virtuals/FileLike

Conversation

@Michicosun

@Michicosun Michicosun commented Mar 31, 2026 •

Copy link
Copy Markdown
Member

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

Part of #100766

Version info

  • Merged into: 26.4.1.484

@clickhouse-gh

clickhouse-gh Bot commented Mar 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6f77c39]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_llvm_coverage, 2/5) failure
test_overcommit_tracker/test.py::test_user_overcommit FAIL cidb
Stress test (amd_asan_ubsan) failure
Server died FAIL cidb
Logical error: Shard number is greater than shard count: shard_num=A shard_count=B cluster=C (STID: 5066-457d) FAIL cidb
Stress test (arm_msan) failure
Server died FAIL cidb
MemorySanitizer: use-of-uninitialized-value (STID: 2410-488a) FAIL cidb

AI Review

Summary

This PR adds a new _table virtual column for file-like storages (File, URL, object-storage readers) by threading StorageID through virtual-column filling. The functional direction looks correct, but there are two merge-blocking quality gaps: compile-time impact from a heavy include added to a widely-used header, and missing test coverage for the new virtual column behavior.

Findings

⚠️ Majors

  • [src/Storages/VirtualColumnUtils.h:5] Adding #include <Interpreters/StorageID.h> to this high-fan-out header introduces unnecessary transitive dependencies (AST/QualifiedTableName/fmt path) into many translation units. VirtualsForFileLikeStorage only stores const StorageID &, so a forward declaration is sufficient and avoids broad recompilation overhead.
    • Suggested fix: forward-declare struct StorageID; in the header and move the full include to VirtualColumnUtils.cpp.
Tests
  • ⚠️ Add stateless coverage for selecting _table from File/URL/object-storage reads and filtering by _table.
  • ⚠️ Add coverage for collision behavior when a real column named _table exists, to ensure virtual-column wiring remains correct.
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 ⚠️ Heavy include added to VirtualColumnUtils.h where forward declaration is sufficient
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions:
    • Replace StorageID.h include in VirtualColumnUtils.h with forward declaration and include the full header only in .cpp.
    • Add dedicated tests for _table virtual column behavior (projection/filtering + name-collision edge case).

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Mar 31, 2026
{"_data_lake_snapshot_version", makeNullable(std::make_shared<DataTypeUInt64>())},
{"_row_number", makeNullable(std::make_shared<DataTypeInt64>())},
{"_iceberg_metadata_file_path", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
{"_table", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ This introduces a new user-visible virtual column (_table) for file-like storages, but this PR doesn't add any tests for it.

Please add stateless coverage for at least:

  • selecting _table from File/URL/object-storage-backed reads;
  • filtering by _table (to ensure virtual-column filtering path stays correct);
  • behavior when a real column named _table exists (virtual should not shadow user schema).

Without this, regressions in virtual-column wiring are easy to miss.

@CheSema CheSema self-assigned this Mar 31, 2026

#include <Columns/ColumnsNumber.h>
#include <Interpreters/Context_fwd.h>
#include <Interpreters/StorageID.h>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding #include <Interpreters/StorageID.h> to VirtualColumnUtils.h brings a heavy header (AST/QualifiedTableName/fmt dependencies) into every translation unit that includes this widely-used storage utility header.

VirtualsForFileLikeStorage only needs a reference type, so a forward declaration is enough in the header:

struct StorageID;

and keep the full include in VirtualColumnUtils.cpp.

This avoids unnecessary transitive recompilation and keeps compile-time impact lower.

@clickhouse-gh

clickhouse-gh Bot commented Apr 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.00% 84.00% +0.00%
Functions 90.90% 90.90% +0.00%
Branches 76.50% 76.50% +0.00%

Changed lines: 96.97% (64/66) · Uncovered code

Full report · Diff report

@Michicosun
Michicosun added this pull request to the merge queue Apr 1, 2026
Merged via the queue into master with commit 8d71dcb Apr 1, 2026
156 of 159 checks passed
@Michicosun
Michicosun deleted the native_common_virtuals/FileLike branch April 1, 2026 11:06
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Apr 1, 2026
nickitat added a commit that referenced this pull request Jun 5, 2026
After removing the `storage_id` initializer, the `26.3` build hit a
second error from the same #105584 backport:

    src/Storages/HivePartitioningUtils.cpp:70:26: error: no member named
    'allow_number_leading_zeros' in 'DB::FormatSettings'

`buildHiveFormatSettings` sets `allow_number_leading_zeros`, but that
`FormatSettings` field was introduced by a separate prerequisite,
"Fix for hive partitioning with leading zeros" (master commit
`1d9caa0d168`), which — like #101409 — was never backported to `26.3`.

Drop the assignment. `26.3` keeps its existing leading-zeros parsing
behavior (consistent with that prerequisite not being backported), while
the actual point of #105584 — honoring `cast_string_to_date_time_mode`
for hive partition values — is preserved.

A full scan of the #105584 backport diff confirms these were the only
two symbols absent on `26.3`; all other referenced symbols
(`convertFieldToType` with `FormatSettings`, `cast_string_to_date_time_mode`,
`buildHiveFormatSettings`) exist on the branch.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106612&sha=5d9df59d9052889a5665790edc4851f56f2fd9e4&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The `26.3` build was broken with:

    src/Storages/StorageFile.cpp:1658:22: error: field designator
    'storage_id' does not refer to any field in type
    'VirtualsForFileLikeStorage'

This was introduced by the backport of ClickHouse#105584 ("Honor
`cast_string_to_date_time_mode` for hive partition values"), which
cherry-picked a `.storage_id = storage->getStorageID()` initializer for
`VirtualsForFileLikeStorage`. On `master` that field exists because it
was added by ClickHouse#101409 ("Native Common Virtuals for File-Like"), but
ClickHouse#101409 was never backported to `26.3`, so the struct here has no
`storage_id` member and the designated initializer fails to compile.

`addRequestedFileLikeStorageVirtualsToChunk` on `26.3` never reads
`storage_id`, so removing the initializer is behavior-preserving and
restores the build for the whole release branch.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106498&sha=b7c045c7bd5bb605b946fe1d77092a02ccef89bb&name_0=BackportPR
Surfaced on PR: ClickHouse#106498

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
After removing the `storage_id` initializer, the `26.3` build hit a
second error from the same ClickHouse#105584 backport:

    src/Storages/HivePartitioningUtils.cpp:70:26: error: no member named
    'allow_number_leading_zeros' in 'DB::FormatSettings'

`buildHiveFormatSettings` sets `allow_number_leading_zeros`, but that
`FormatSettings` field was introduced by a separate prerequisite,
"Fix for hive partitioning with leading zeros" (master commit
`1d9caa0d168`), which — like ClickHouse#101409 — was never backported to `26.3`.

Drop the assignment. `26.3` keeps its existing leading-zeros parsing
behavior (consistent with that prerequisite not being backported), while
the actual point of ClickHouse#105584 — honoring `cast_string_to_date_time_mode`
for hive partition values — is preserved.

A full scan of the ClickHouse#105584 backport diff confirms these were the only
two symbols absent on `26.3`; all other referenced symbols
(`convertFieldToType` with `FormatSettings`, `cast_string_to_date_time_mode`,
`buildHiveFormatSettings`) exist on the branch.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=106612&sha=5d9df59d9052889a5665790edc4851f56f2fd9e4&name_0=BackportPR

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

3 participants