**Does it reproduce on recent release?**
Reproduced on 21.11.1.1 (master) and 21.9.2
Works as expected on 21.8.2, so it's regression

**How to reproduce**
```
:) create table mt (id Int64, A Nullable(Int64), X Int64 materialized coalesce(A, -1)) engine=MergeTree order by id
:) insert into mt values (1, 42)  -- X will be 42 (as expected)
:) insert into mt select 1, 42    -- X will be -1
:) select *, X from mt order by id
┌─id─┬──A─┬──X─┐
│  1 │ 42 │ 42 │
└────┴────┴────┘
┌─id─┬──A─┬──X─┐
│  1 │ 42 │ -1 │
└────┴────┴────┘
```

**Expected behavior**

```
:) select *, X from mt order by id
┌─id─┬──A─┬──X─┐
│  1 │ 42 │ 42 │
└────┴────┴────┘
┌─id─┬──A─┬──X─┐
│  1 │ 42 │ 42 │
└────┴────┴────┘
```

if (column_default)
    {
        
        auto column_default_expr = column_default->expression->clone();
        
        
        RequiredSourceColumnsVisitor::Data columns_context;
        RequiredSourceColumnsVisitor(columns_context).visit(column_default_expr);
        NameSet required_columns_names = columns_context.requiredColumns();
        auto expr = makeASTFunction("_CAST", column_default_expr, std::make_shared<ASTLiteral>(columns.get(required_column_name).type->getName()));
        if (is_column_in_query && convert_null_to_default)
            expr = makeASTFunction("ifNull", std::make_shared<ASTIdentifier>(required_column_name), std::move(expr));
        default_expr_list_accum->children.emplace_back(setAlias(expr, required_column_name));
        added_columns.emplace(required_column_name);
        for (const auto & next_required_column_name : required_columns_names)
            addDefaultRequiredExpressionsRecursively(block, next_required_column_name, required_column_type, columns, default_expr_list_accum, added_columns, null_as_default);
    }
    else if (columns.has(required_column_name))
    {
        
        
        
        auto column = columns.get(required_column_name);
        auto default_value = column.type->getDefault();
        auto default_ast = std::make_shared<ASTLiteral>(default_value);
        default_expr_list_accum->children.emplace_back(setAlias(default_ast, required_column_name));
        added_columns.emplace(required_column_name);
    }
}
ASTPtr defaultRequiredExpressions(const Block & block, const NamesAndTypesList & required_columns, const ColumnsDescription & columns, bool null_as_default)