Newer versions can't clear columns which are used in default expressions for other columns. Maybe it's caused by https://github.com/ClickHouse/ClickHouse/issues/6913

CH version 20.5.2


create database Temp;
create table Temp.Test (`impression_id` String,`impression_id_compressed` FixedString(16) DEFAULT UUIDStringToNum(substring(impression_id, 1, 36)), `impression_id_hashed` UInt16 DEFAULT reinterpretAsUInt16(impression_id_compressed), `event_date` Date ) ENGINE = MergeTree(event_date, impression_id_hashed, (event_date, impression_id_hashed), 8192);
alter table Temp.Test clear column `impression_id` in partition '202001';


Received exception from server (version 20.5.2):
Code: 44. DB::Exception: Received from ch7r1.local:9000. DB::Exception: Cannot drop column `impression_id`, because column `impression_id_compressed` depends on it. 




Older versions (tested with 19.17.4 and 20.3.5):

CREATE DATABASE Temp;
create table Temp.Test (`impression_id` String,`impression_id_compressed` FixedString(16) DEFAULT UUIDStringToNum(substring(impression_id, 1, 36)), `impression_id_hashed` UInt16 DEFAULT reinterpretAsUInt16(impression_id_compressed), `event_date` Date ) ENGINE = MergeTree(event_date, impression_id_hashed, (event_date, impression_id_hashed), 8192);
alter table Temp.Test clear column `impression_id` in partition '202001';

ALTER TABLE Temp.Test
    CLEAR COLUMN impression_id     IN PARTITION '202001'


Ok.

{
            command.default_kind = columnDefaultKindFromString(ast_col_decl.default_specifier);
            command.default_expression = ast_col_decl.default_expression;
        }
        if (ast_col_decl.comment)
        {
            const auto & ast_comment = ast_col_decl.comment->as<ASTLiteral &>();
            command.comment.emplace(ast_comment.value.get<String>());
        }
        if (ast_col_decl.ttl)
            command.ttl = ast_col_decl.ttl;
        if (ast_col_decl.codec)
            command.codec = compression_codec_factory.get(ast_col_decl.codec, command.data_type, sanity_check_compression_codecs);
        if (command_ast->column)
            command.after_column = getIdentifierName(command_ast->column);
        command.first = command_ast->first;
        command.if_exists = command_ast->if_exists;
        return command;
    }
    else if (command_ast->type == ASTAlterCommand::COMMENT_COLUMN)
    {
        AlterCommand command;
        command.ast = command_ast->clone();
        command.type = COMMENT_COLUMN;
        command.column_name = getIdentifierName(command_ast->column);
        const auto & ast_comment = command_ast->comment->as<ASTLiteral &>();
        command.comment = ast_comment.value.get<String>();
        command.if_exists = command_ast->if_exists;
        return command;
    }