```
CREATE TABLE a
(
    `number` UInt64,
    `x` MATERIALIZED x
)
ENGINE = MergeTree
ORDER BY number;
-- that should fail!

insert into a values (1);
Received exception from server (version 21.7.1):
Code: 47. DB::Exception: Received from localhost:9000. DB::Exception: Missing columns: 'x' while processing query: 'CAST(x, 'UInt8') AS x', required columns: 'x' 'x'. 
```
ASTPtr & query,
    const NamesAndTypesList & source_columns,
    ConstStoragePtr storage,
    const StorageMetadataPtr & metadata_snapshot,
    bool allow_aggregations) const
{
    if (query->as<ASTSelectQuery>())
        throw Exception("Not select analyze for select asts.", ErrorCodes::LOGICAL_ERROR);
    const auto & settings = getContext()->getSettingsRef();
    TreeRewriterResult result(source_columns, storage, metadata_snapshot, false);
    normalize(query, result.aliases, result.source_columns_set, false, settings);
    
    executeScalarSubqueries(query, getContext(), 0, result.scalars, false);
    TreeOptimizer::optimizeIf(query, result.aliases, settings.optimize_if_chain_to_multiif);
    if (allow_aggregations)
    {
        GetAggregatesVisitor::Data data;
        GetAggregatesVisitor(data).visit(query);
        
        for (const ASTFunction * node : data.aggregates)
            for (auto & arg : node->arguments->children)
                assertNoAggregates(arg, "inside another aggregate function");
        result.aggregates = data.aggregates;
    }
    else
        assertNoAggregates(query, "in wrong place");
    result.collectUsedColumns(query, false);
    return std::make_shared<const TreeRewriterResult>(result);
}
void TreeRewriter::normalize(