Looks like https://github.com/ClickHouse/ClickHouse/pull/21303 is broke also "clear column" for such columns.

How to reproduce:

```
CREATE TABLE test.TTAdmLog
(
    `ts` DateTime,
    `event_date` Date DEFAULT toDate(ts),
    `impression_id` String DEFAULT '',
    `creative_id` String DEFAULT '',
    `creative_adm` String DEFAULT '',
    `impression_id_compressed` FixedString(16) DEFAULT UUIDStringToNum(impression_id),
    `impression_id_hashed` UInt16 DEFAULT reinterpretAsUInt16(impression_id_compressed),
)
ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/TTAdmLogTest', '{replica}')
PARTITION BY toMonday(event_date)
ORDER BY (event_date, impression_id_hashed)
SAMPLE BY impression_id_hashed
SETTINGS replicated_deduplication_window = 1000, replicated_deduplication_window_seconds = 864000, index_granularity = 8192

CREATE MATERIALIZED VIEW test.TTView
(
    `event_date` Date,
    `creative_id` String,
    `creative_adm` AggregateFunction(anyLast, String),
)
ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{shard}/TTViewTest', '{replica}', event_date, (event_date, creative_id), 8192) AS
SELECT 
    toStartOfMonth(event_date) AS event_date,
    arrayJoin(splitByChar(',', creative_id)) AS creative_id,
    anyLastState(creative_adm) AS creative_adm,
FROM test.TTAdmLog
GROUP BY 
    event_date,
    creative_id,

```


ClickHouse server version 20.9.3 revision 54439.

```
alter table test.TTAdmLog clear column creative_adm in partition '2021-03-22'

OK

```
ClickHouse server version 21.4.3 revision 54447.

```
alter table test.TTAdmLog  clear column creative_adm in partition '2021-03-22'

DB::Exception: Trying to ALTER DROP column creative_adm which is referenced by materialized view ['TTView'].

```

}
    }
    auto all_columns = new_metadata.columns.getAllPhysical();
    
    if (old_metadata.hasSortingKey())
    {
        
        
        Names new_primary_key_columns = new_primary_key.column_names;
        Names new_sorting_key_columns = new_sorting_key.column_names;
        ASTPtr added_key_column_expr_list = std::make_shared<ASTExpressionList>();
        const auto & old_sorting_key_columns = old_metadata.getSortingKeyColumns();
        for (size_t new_i = 0, old_i = 0; new_i < sorting_key_size; ++new_i)
        {
            if (old_i < old_sorting_key_columns.size())
            {
                if (new_sorting_key_columns[new_i] != old_sorting_key_columns[old_i])
                    added_key_column_expr_list->children.push_back(new_sorting_key.expression_list_ast->children[new_i]);
                else
                    ++old_i;
            }
            else
                added_key_column_expr_list->children.push_back(new_sorting_key.expression_list_ast->children[new_i]);
        }
        if (!added_key_column_expr_list->children.empty())
        {
            auto syntax = TreeRewriter(getContext()).analyze(added_key_column_expr_list, all_columns);
            Names used_columns = syntax->requiredSourceColumns();
            NamesAndTypesList deleted_columns;
            NamesAndTypesList added_columns;