```
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'. 
```
NameToNameMap array_join_alias_to_name;
    
    
    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;
    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(); }
    NameSet getArrayJoinSourceNameSet() const;
    const Scalars & getScalars() const { return scalars; }
};
using TreeRewriterResultPtr = std::shared_ptr<const TreeRewriterResult>;
class TreeRewriter : WithConstContext