**Describe what's wrong**

After Moving to 21.11, [ReplacingMergeTree-style Materialized view](https://github.com/tiniumv/clickhouse_bug/blob/main/migrations/add_view.sql) which is getting data from [two other views](https://github.com/tiniumv/clickhouse_bug/blob/main/migrations/basic.sql) based on kafka topics stopped to receive any data.

Same requst ```select * from causing_problems_mv;```
on 21.10
```
┌─field_a─┬─field_b─┬─field_c─┬──max_field_datetime─┐
│ 1       │ type_a  │       1 │ 2021-12-01 14:00:00 │
│ 2       │ type_a  │       2 │ 2021-12-01 13:00:00 │
└─────────┴─────────┴─────────┴─────────────────────┘
```
and on 21.11
```
0 rows in set. Elapsed: 0.002 sec.
```

Moreover, one of the source view (the one from left part of ```LEFT JOIN``` expression) went broken too. That was isolated - I tried to not create final view under 21.11, and it resulted in basic views working normally.

**Does it reproduce on recent release?**

Yes.

**How to reproduce**

Repository with everything needed to replicate bug: https://github.com/tiniumv/clickhouse_bug . There are two branches, main (with 21.10 CH) and 21.11

**Expected behavior**

I was expecting result of provided queries to be identical independently from ClickHouse version.

**Error message and/or stacktrace**

[I have collected all logs](https://raw.githubusercontent.com/tiniumv/clickhouse_bug/21.11/logs/clickhouse-server.err.log)
it says that ```Column `field_a` is not under aggregate function and not in GROUP BY: While processing field_a, field_b, argMax(field_c, field_datetime) AS field_c, max(field_datetime) AS max_field_datetime.```, but it clearly is

**Additional context**

While request ```select * from table_ii;``` returns nothing, ```select * from table_ii_queue;``` spits out all lost messages

all_source_columns_set.insert(name);
    }
    normalize(query, result.aliases, all_source_columns_set, select_options.ignore_alias, settings,  true);
    
    
    
    
    removeUnneededColumnsFromSelectClause(select_query, required_result_columns, remove_duplicates);
    
    executeScalarSubqueries(query, getContext(), subquery_depth, result.scalars, select_options.only_analyze);
    if (settings.legacy_column_name_of_tuple_literal)
        markTupleLiteralsAsLegacy(query);
    
    result.rewrite_subqueries = PredicateExpressionsOptimizer(getContext(), tables_with_columns, settings).optimize(*select_query);
    TreeOptimizer::optimizeIf(query, result.aliases, settings.optimize_if_chain_to_multiif);
    
    if (getContext()->getClientInfo().query_kind == ClientInfo::QueryKind::INITIAL_QUERY)
        TreeOptimizer::apply(query, result, tables_with_columns, getContext());
    
    getArrayJoinedColumns(query, result, select_query, result.source_columns, source_columns_set);
    setJoinStrictness(
        *select_query, settings.join_default_strictness, settings.any_join_distinct_right_table_keys, result.analyzed_join->table_join);
    auto * table_join_ast = select_query->join() ? select_query->join()->table_join->as<ASTTableJoin>() : nullptr;
    if (table_join_ast && tables_with_columns.size() >= 2)
        collectJoinedColumns(*result.analyzed_join, *table_join_ast, tables_with_columns, result.aliases, getContext());
    result.aggregates = getAggregates(query, *select_query);
    result.window_function_asts = getWindowFunctions(query, *select_query);
    result.collectUsedColumns(query, true);
    result.required_source_columns_before_expanding_alias_columns = result.required_source_columns.getNames();