```
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'. 
```
struct ASTTablesInSelectQueryElement;
class TableJoin;
struct Settings;
struct SelectQueryOptions;
using Scalars = std::map<String, Block>;
struct StorageInMemoryMetadata;
using StorageMetadataPtr = std::shared_ptr<const StorageInMemoryMetadata>;
struct TreeRewriterResult
{
    ConstStoragePtr storage;
    StorageMetadataPtr metadata_snapshot;
    std::shared_ptr<TableJoin> analyzed_join;
    const ASTTablesInSelectQueryElement * ast_join = nullptr;
    NamesAndTypesList source_columns;
    NameSet source_columns_set; 
    
    NamesAndTypesList required_source_columns;
    Aliases aliases;
    std::vector<const ASTFunction *> aggregates;
    std::vector<const ASTFunction *> window_function_asts;
    
    
    NameToNameMap array_join_result_to_source;