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.

settings_from_storage.push_back(change);
        }
    }
    else if (type == RENAME_COLUMN)
    {
        metadata.columns.rename(column_name, rename_to);
        RenameColumnData rename_data{column_name, rename_to};
        RenameColumnVisitor rename_visitor(rename_data);
        for (const auto & column : metadata.columns)
        {
            metadata.columns.modify(column.name, [&](ColumnDescription & column_to_modify)
            {
                if (column_to_modify.default_desc.expression)
                    rename_visitor.visit(column_to_modify.default_desc.expression);
                if (column_to_modify.ttl)
                    rename_visitor.visit(column_to_modify.ttl);
            });
        }
        if (metadata.table_ttl.definition_ast)
            rename_visitor.visit(metadata.table_ttl.definition_ast);
        for (auto & constraint : metadata.constraints.constraints)
            rename_visitor.visit(constraint);
        if (metadata.isSortingKeyDefined())
            rename_visitor.visit(metadata.sorting_key.definition_ast);
        if (metadata.isPrimaryKeyDefined())
            rename_visitor.visit(metadata.primary_key.definition_ast);
        if (metadata.isSamplingKeyDefined())
            rename_visitor.visit(metadata.sampling_key.definition_ast);
        if (metadata.isPartitionKeyDefined())
            rename_visitor.visit(metadata.partition_key.definition_ast);