Fix create statement when using default minmax indicies#91429
Fix create statement when using default minmax indicies#91429Algunenano merged 7 commits intoClickHouse:masterfrom
Conversation
|
Workflow [PR], commit [3a2c52f] Summary: ❌
|
There was a problem hiding this comment.
Pull request overview
This PR fixes issues with implicit minmax indices created by settings add_minmax_index_for_numeric_columns and add_minmax_index_for_string_columns. The key change is that these implicit indices are now excluded from CREATE statements and ReplicatedMergeTree metadata, preventing version incompatibility issues. The PR also fixes implicit index handling when column types change and for ephemeral/alias columns.
Key Changes
- Implicit indices are now tracked with an
is_implicitly_createdflag instead of relying on name prefix detection - CREATE statements and keeper metadata no longer include implicit indices (using new
explicitToString()method) - Type changes on columns now properly update their implicit indices
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Storages/IndicesDescription.h | Added is_implicitly_created flag and split toString() into explicitToString() and allToString() methods |
| src/Storages/IndicesDescription.cpp | Implemented explicit/all string conversion and updated index parsing to accept is_implicitly_created parameter |
| src/Storages/StorageInMemoryMetadata.h | Added implicit index settings flags and helper methods for managing implicit indices |
| src/Storages/StorageInMemoryMetadata.cpp | Implemented addImplicitIndicesForColumn() and dropImplicitIndicesForColumn() with validation |
| src/Storages/MergeTree/registerStorageMergeTree.cpp | Refactored implicit index creation to use new helper methods |
| src/Storages/MergeTree/ReplicatedMergeTreeTableMetadata.cpp | Updated to use explicitToString() for metadata comparison with backward compatibility check |
| src/Storages/StorageReplicatedMergeTree.cpp | Changed to use explicitToString() when comparing indices for alter operations |
| src/Storages/AlterCommands.cpp | Simplified ALTER logic to use new helper methods and handle type changes |
| src/Storages/MergeTree/MergeTreeIndices.h | Exposed implicitValidation() method |
| src/Storages/MergeTree/MergeTreeIndices.cpp | Extracted validation logic to be reusable for implicit index creation |
| src/Storages/MergeTree/PatchParts/RangesInPatchParts.cpp | Updated to check isImplicitlyCreated() flag instead of name prefix |
| src/Interpreters/InterpreterCreateQuery.cpp | Filtered out implicit indices when formatting CREATE statements |
| src/Databases/DatabasesCommon.cpp | Updated validation to pass is_implicitly_created parameter |
| tests/queries/0_stateless/03632_default_minmax_indices_alter.sql | Test for basic ALTER with implicit indices |
| tests/queries/0_stateless/03632_default_minmax_indices_alter.reference | Expected output for basic ALTER test |
| tests/queries/0_stateless/03748_default_minmax_indices_alter.sql | Comprehensive ALTER test covering type changes and renames |
| tests/queries/0_stateless/03748_default_minmax_indices_alter.reference | Expected output for comprehensive ALTER test |
| tests/queries/0_stateless/03749_implicit_index_ephemeral_alias.sql | Test for implicit indices with ephemeral and alias columns |
| tests/queries/0_stateless/03749_implicit_index_ephemeral_alias.reference | Expected output for ephemeral/alias column test |
| if (!index.isImplicitlyCreated()) | ||
| list.children.push_back(index.definition_ast); |
There was a problem hiding this comment.
Add a comment explaining that only explicit indices are included in the output string to maintain backward compatibility and prevent metadata mismatches between versions.
Co-authored-by: Copilot <[email protected]>
5f1325f
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Multiple fixes around implicit indices. The schema shown or stored (keeper metadata) won't include implicit indices, such as the ones created by settings
add_minmax_index_for_numeric_columnsoradd_minmax_index_for_string_columns. This might cause metadata errors when a ReplicatedMergeTree table is created or updated in a newer version, while there is a replica in an older release. For those cases send DDLs to the old replica until the cluster is upgraded completely.This PR:
Closes #87286.
Closes #87723
Documentation entry for user-facing changes