v.18.16New Feature
ALTER TABLE now supports MODIFY ORDER BY for sorting key changes in MergeTree tables
TheALTER TABLEquery now has theMODIFY ORDER BYaction for changing the sorting key when adding or removing a table column. This is useful for tables in theMergeTreefamily that perform additional tasks when merging based on this sorting key, such asSummingMergeTree,AggregatingMergeTree, and so on. #3581 #3755
Why it matters
This feature allows users to modify the sorting key ofMergeTree-based tables during schema changes such as adding or removing columns. It solves the problem of not being able to update the sorting key without recreating the table, which is essential for tables performing merges with special logic like SummingMergeTree and AggregatingMergeTree.How to use it
Use theALTER TABLE query with the MODIFY ORDER BY clause to change the sorting key. For example:ALTER TABLE table_name MODIFY ORDER BY (new_sorting_key)This can be combined with adding or removing columns in the same query.