```
DROP TABLE IF EXISTS foo;

CREATE TABLE foo (timestamp DateTime, x UInt64)
ENGINE = MergeTree PARTITION BY toYYYYMMDD(timestamp)
ORDER BY (timestamp);

INSERT INTO foo (timestamp, x) SELECT toDateTime('2020-01-01 00:05:00'), number from system.numbers_mt LIMIT 100;

SELECT count() FROM system.mutations; -- ok

ALTER TABLE foo UPDATE x = 1 WHERE x = (SELECT x from foo WHERE x = 1);

SELECT count() FROM system.mutations; -- stuck

```
NameToNameMap array_join_name_to_alias;
    
    bool rewrite_subqueries = false;
    
    
    bool has_explicit_columns = false;
    
    
    
    bool optimize_trivial_count = false;
    
    bool is_remote_storage = false;
    
    Scalars scalars;
    explicit TreeRewriterResult(
        const NamesAndTypesList & source_columns_,
        ConstStoragePtr storage_ = {},
        const StorageMetadataPtr & metadata_snapshot_ = {},
        bool add_special = true);
    void collectSourceColumns(bool add_special);
    void collectUsedColumns(const ASTPtr & query, bool is_select);
    Names requiredSourceColumns() const { return required_source_columns.getNames(); }
    const Names & requiredSourceColumnsForAccessCheck() const { return required_source_columns_before_expanding_alias_columns; }
    NameSet getArrayJoinSourceNameSet() const;
    const Scalars & getScalars() const { return scalars; }
};
using TreeRewriterResultPtr = std::shared_ptr<const TreeRewriterResult>;
class TreeRewriter : WithContext