diff --git a/src/Storages/AlterCommands.cpp b/src/Storages/AlterCommands.cpp index 33a62d9bd1c..5652d1717ec 100644 --- a/src/Storages/AlterCommands.cpp +++ b/src/Storages/AlterCommands.cpp @@ -313,6 +313,9 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata, const Context & con column.default_desc.expression = default_expression; } }); + + if (metadata.sorting_key.sample_block.has(column_name)) + metadata.sorting_key = KeyDescription::getKeyFromAST(metadata.sorting_key.definition_ast, metadata.columns, context); } else if (type == MODIFY_ORDER_BY) {