Repository navigation
Support Virtual Columns for Granule MinMax Index - #104746
Conversation
|
Workflow [PR], commit [76809c4] Summary: ❌
AI ReviewSummaryThis PR adds implicit min-max index support for persistent virtual columns Findings❌ Blockers
Tests
Final VerdictStatus:
|
2c3cba8 to
084dc9c
Compare
|
How does this compare to the |
I created a commit-order projection to support table reading in a row commit order without resorting at runtime. It is necessary to omit sorting large data sets. Initially, I made it to support streaming queries on top of the merge tree engine. |
|
I see. I had assumed the |
|
I curios about the case when we add this index on the existed table. And how it would work for old parts where block number is not set for the rows. This behavior should be in descriptoin/documentation. |
When the block number column is materialized on disk, the index will be written. For parts where the block number column was not materialized, it will be materialized with the part's minimum block number and written to the index with the same value. |
| any_mt_setting = true; | ||
| } | ||
| } | ||
| if (any_mt_setting) |
There was a problem hiding this comment.
RESET SETTING still bypasses this metadata/index resync.
Concrete path:
CREATE TABLE ... SETTINGS add_minmax_index_for_block_number_column = 1, enable_block_number_column = 1(implicitauto_minmax_index__block_numberis present)ALTER TABLE ... RESET SETTING enable_block_number_column
settings_changes is updated in the RESET_SETTING branch below, but the recalculation of metadata.add_minmax_index_for_block_* and metadata.secondary_indices is not re-run there. So the stale implicit virtual index remains in metadata even though the setting was reset to default (0).
Can we run the same recompute + dropImplicitIndicesForVirtualColumns/addImplicitIndicesForVirtualColumns flow for RESET_SETTING too?
|
|
||
| auto using_auto_minmax_index = metadata.add_minmax_index_for_numeric_columns || metadata.add_minmax_index_for_string_columns | ||
| || metadata.add_minmax_index_for_temporal_columns; | ||
| auto using_auto_minmax_index = |
There was a problem hiding this comment.
using_auto_minmax_index here is derived from metadata.add_minmax_index_for_block_*, which is persisted as add_* && enable_*.
That means CREATE TABLE ... SETTINGS add_minmax_index_for_block_number_column = 1, enable_block_number_column = 0 does not reserve the auto_minmax_index__block_number prefix, so users can create an explicit index with that reserved name.
Later ALTER TABLE ... MODIFY SETTING enable_block_number_column = 1 calls addImplicitIndicesForVirtualColumns, which only checks index.column_names.front() == _block_number; it does not guard against an existing explicit index with the same reserved name on another expression. This can append a second index named auto_minmax_index__block_number and break the unique-name invariant for secondary_indices.
Can we keep reserved-name protection based on raw add_* intent (or reject enabling when a reserved-name explicit index already exists)?
|
|
||
| auto using_auto_minmax_index = metadata.add_minmax_index_for_numeric_columns || metadata.add_minmax_index_for_string_columns | ||
| || metadata.add_minmax_index_for_temporal_columns; | ||
| auto using_auto_minmax_index = |
There was a problem hiding this comment.
ADD INDEX still uses metadata.add_minmax_index_for_block_* (which is persisted as add_* && enable_*) to decide whether the auto_minmax_index__* prefix is reserved.
That leaves a live gap:
CREATE TABLE ... SETTINGS add_minmax_index_for_block_number_column = 1, enable_block_number_column = 0ALTER TABLE ... ADD INDEX auto_minmax_index__block_number (a) TYPE minmax GRANULARITY 1(accepted here)ALTER TABLE ... MODIFY SETTING enable_block_number_column = 1
At step 3, addImplicitIndicesForVirtualColumns can append an implicit auto_minmax_index__block_number for _block_number, so secondary_indices can end up with duplicate reserved names.
Can we reserve the prefix based on the raw add_* intent (or reject enabling when such explicit reserved-name indices already exist), same as the create-path fix?
LLVM Coverage Report
Changed lines: 99.03% (205/207) | lost baseline coverage: 3 line(s) · Uncovered code |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
This patch adds the ability to create a granule-level implicit min-max index for virtual columns block number and block offset, which, combined with #103952, can help filter all data based on the virtual block number and block offset predicates.
Version info
26.5.1.692