Skip to content

Add skipping_indices_types column to system.tables - #106388

Merged
CurtizJ merged 14 commits into
ClickHouse:masterfrom
CurtizJ:system-tables-skip-indexes
Aug 3, 2026
Merged

CurtizJ merged 14 commits into
ClickHouse:masterfrom
CurtizJ:system-tables-skip-indexes

Conversation

@CurtizJ

@CurtizJ CurtizJ commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Added a new column skipping_indices_types to the system.tables table. It contains the distinct types of data-skipping indices defined for each table.

Version info

  • Merged into: 26.8.1.673 (included in 26.8 and later)

Expose the distinct, sorted set of data skipping index types defined on
each table through a new `skipping_indices_types` `Array(String)` column
in `system.tables`. The types are collected from `getSecondaryIndices`
and deduplicated via a `std::set`, so a table with two `minmax` indices
reports `minmax` once, and the result is deterministically sorted. The
array is empty for tables without skip indices and for non-`MergeTree`
engines.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [205608d]

Summary: ✅


AI Review

Summary

This PR adds the system.tables.skipping_indices_types column, fills it from explicit secondary-index metadata, covers the temporary-table path, updates the generated docs and SHOW CREATE TABLE system.tables reference, and adds focused stateless tests for deduplication, ordering, temporary tables, and implicit minmax indices. I did not find any remaining correctness or contract issues in the current PR head, and the latest Praktika report for PR #106388 is all-green.

Final Verdict
  • Status: ✅ Approve
  • No new inline findings to post. The earlier bot-raised issues around temporary-table column alignment, temporary-table population, implicit indices, and docs ordering are fixed in the current code.

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 3, 2026
Ergus
Ergus previously requested changes Jun 4, 2026
@Ergus Ergus self-assigned this Jun 4, 2026
@CurtizJ

CurtizJ commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

@groeneai continue with this PR: resolve review comments and fix failed tests.

Adding the skipping_indices_types column shifted the positional column
indices, but the temporary-table branch in TablesBlockSource still
hardcoded src_index 21 for total_rows and 22 for total_bytes. With the
new schema order those positions are storage_policy (21), total_rows
(22) and total_bytes (23), so for a session temporary table the String
column storage_policy received the UInt64 total_rows value and failed
with "Bad get: has UInt64, requested String (BAD_GET)".

Bump the two hardcoded indices to 22 and 23 to match the new order.

Fixes the Fast test failures on PR ClickHouse#106388:
00693_max_block_size_system_tables_columns,
00080_show_tables_and_system_tables (both BAD_GET) and
02271_temporary_table_show_rows_bytes (wrong values).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

@CurtizJ done. We do not have push access to your fork (maintainerCanModify only grants org members), so the fix is a one-click PR into this branch: CurtizJ#1.

Root cause of Ergus's CHANGES_REQUESTED and the 3 Fast test failures is the same off-by-one: skipping_indices_types lands at column 20, shifting total_rows to 22 and total_bytes to 23, but the temporary-table branch still hardcoded 21 and 22. So for a session temp table, storage_policy (String, now 21) got the UInt64 total_rows and threw Bad get: has UInt64, requested String (BAD_GET).

Diff (the two spots Ergus flagged, StorageSystemTables.cpp):

-                            else if (src_index == 21 && columns_mask[src_index])
+                            else if (src_index == 22 && columns_mask[src_index])
                             {  // total_rows
...
-                            else if (src_index == 22 && columns_mask[src_index])
+                            else if (src_index == 23 && columns_mask[src_index])
                             {  // total_bytes

Verified on a debug build, all four now pass (was failing): 00693_max_block_size_system_tables_columns, 00080_show_tables_and_system_tables (both were BAD_GET), 02271_temporary_table_show_rows_bytes, and 04311 (your new test).

Merge CurtizJ#1 and CI will rerun.

@clickhouse-gh

clickhouse-gh Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Dear @Ergus, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself.

Fix column index in temporary-table path of system.tables
The temporary-table branch in TablesBlockSource only special-cased
parameterized_view_parameters, total_rows and total_bytes; every other
late column fell through to insertDefault(). So the new
skipping_indices_types column at position 20 always showed [] for
session temporary MergeTree tables. Add a temp-table case for it,
sharing a fillSkippingIndicesTypes() helper with the non-temp path,
and extend the regression test with a temporary MergeTree table.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

Good catch. The temp-table branch in TablesBlockSource only special-cased parameterized_view_parameters, total_rows and total_bytes; the new skipping_indices_types slot fell through to insertDefault(), so session temporary MergeTree tables always showed [].

Fixed by adding a temp-table case for that slot, sharing a fillSkippingIndicesTypes() helper with the non-temp path (schema-derived from the table metadata, no new hardcoded assumptions). Added a regression: a CREATE TEMPORARY TABLE ... ENGINE = MergeTree ... INDEX ... TYPE minmax/set now reports ['minmax','set'] in 04311_system_tables_skipping_indices_types.

We do not have push access to this branch, so the change is a one-click PR into it: CurtizJ#2 (@ CurtizJ). Verified locally on a debug build.

Populate skipping_indices_types for session temporary tables
@CurtizJ

CurtizJ commented Jul 12, 2026

Copy link
Copy Markdown
Member Author

@groeneai fix build.

Master changed IStorage::getInMemoryMetadataPtr to return StorageMetadataHandle,
whose rvalue operator StorageMetadataPtr() is deleted. The temporary-table branch
passed the handle rvalue straight into fillSkippingIndicesTypes (takes
const StorageMetadataPtr &), invoking the deleted conversion. Bind it to a named
local first so the lvalue conversion operator is used.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

@CurtizJ Build fixed. Root cause: master changed getInMemoryMetadataPtr to return StorageMetadataHandle (rvalue operator StorageMetadataPtr() deleted); the temp-table branch passed the handle rvalue into fillSkippingIndicesTypes, hitting the deleted conversion at StorageSystemTables.cpp:646. Fix binds it to a named local first (as the non-temp path does). One-click PR into your branch: CurtizJ#3. Verified: debug build clean, 04311 output unchanged.

Fix build: store StorageMetadataHandle in a local before conversion
…indices_types

getSecondaryIndices() includes implicitly added skip indices (e.g. from
add_minmax_index_for_numeric_columns) as well as explicit INDEX clauses.
The column is documented as the skip-index types defined on the table, so
filter out index.isImplicitlyCreated() to report only user-defined types.
Matches how the create statement (IndicesDescription) omits implicit indices
and how system.data_skipping_indices marks them via its creation column.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator

Fixed. fillSkippingIndicesTypes() now filters !index.isImplicitlyCreated(), so both the non-temp and temp-table paths report only user-defined skip index types per the documented contract. A table with add_minmax_index_for_numeric_columns = 1 and no explicit INDEX now reports [] (the implicit minmax indices still show in system.data_skipping_indices with creation=Implicit). Regression coverage added to 04311.

@CurtizJ no push access to your fork, so it is a one-click merge: CurtizJ#4 (base system-tables-skip-indexes).

Exclude implicitly created skip indices from system.tables.skipping_indices_types
@alexey-milovidov

Copy link
Copy Markdown
Member

Your PR was poisoned by the test 02346_text_index_bug108519_qcc_skip_index. It is fixed in master. Please update the branch.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Branch updated: merged current master (carrying the #110260 fix for 02346_text_index_bug108519_qcc_skip_index) via CurtizJ#5. One-click merge and CI reruns on fresh master.

@groeneai

Copy link
Copy Markdown
Collaborator

Regenerated the AUTOGENERATED block in docs/en/operations/system-tables/tables.md via utils/generate-system-tables-docs so skipping_indices_types matches the source order (before storage_policy). Moved the richer description into the StorageSystemTables.cpp column comment (source of truth the generator emits) and added the column to the SELECT * example.

No push access to this fork, so contributed as one-click PR CurtizJ#6 (base system-tables-skip-indexes). Merge it and the branch updates.

alexey-milovidov and others added 2 commits July 21, 2026 14:25
Move skipping_indices_types in the AUTOGENERATED block of
docs/en/operations/system-tables/tables.md to match its source registration
order (before storage_policy) by regenerating from the binary via
utils/generate-system-tables-docs. Move the richer column description into the
source metadata comment in StorageSystemTables.cpp so the generator emits it,
and add the column to the SELECT * example.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

Branch updated directly (push access via maintainer edits works now, no more one-click PRs needed):

Fork PRs CurtizJ#5 and CurtizJ#6 are obsolete and can be closed.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov Closed CurtizJ#5 and #6. Thanks for taking over the branch.

@alexey-milovidov

Copy link
Copy Markdown
Member

Branch updated: merged current master (`754b6d6433f`).

The only red was Integration tests (amd_tsan, 3/6) — test_replicated_database/test.py::test_replicated_table_structure_alter, the known flake #110036, which was closed on 2026-07-24, i.e. after the previous merge point. Merging master pulls the fix in, so CI should be green on the rerun.

Verified after the merge: the temp-table src_index constants in StorageSystemTables.cpp still line up with the column order (14 parameterized_view_parameters, 20 skipping_indices_types, 22 total_rows, 23 total_bytes), the 02117_show_create_table_system reference and the autogenerated docs block are still in source order, and StorageSystemTables.cpp.o compiles clean.

@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner August 1, 2026 15:51
@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 32/32 (100.00%) · Uncovered code

Full report · Diff report

@CurtizJ CurtizJ 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.

LGTM

@CurtizJ
CurtizJ dismissed Ergus’s stale review August 3, 2026 12:24

Review comments were fixed.

@CurtizJ
CurtizJ added this pull request to the merge queue Aug 3, 2026
Merged via the queue into ClickHouse:master with commit 7039251 Aug 3, 2026
178 checks passed
@CurtizJ
CurtizJ deleted the system-tables-skip-indexes branch August 3, 2026 13:03
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements 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.

5 participants