Hello, there. Run into the problem with DISTINCT expression. It works incorrectly on the main query if it was already applied to one of the subqueries bond with UNION ALL.

**How to reproduce**
Server version: 20.5.4.40. 19.17.6.36 was free of the bug.
Using Datagrip for running queries.
Non-default settings:
```
input_format_defaults_for_omitted_fields: 1
decimal_check_overflow: 0
joined_subquery_requires_alias: 0
```

Consider following query
```
select distinct number
from ((select number from numbers(10)) union all (select number from numbers(20)));
```
It works fine, returning 20 rows as expected.

But if we add distinct to subqueries (it doesn't matter to the first, the second or both)
```
select distinct number
from ((select distinct number from numbers(10)) union all (select distinct number from numbers(20)));
```

Then in 20.5.4.40 we'll see 30 rows with numbers from 0 to 9 duplicated.
However, `count(distinct number)` returns the correct number of rows.

namespace DB
{
namespace ErrorCodes
{
    extern const int LOGICAL_ERROR;
}
namespace
{
const std::unordered_set<String> possibly_injective_function_names
{
        "dictGet",
        "dictGetString",
        "dictGetUInt8",
        "dictGetUInt16",
        "dictGetUInt32",
        "dictGetUInt64",
        "dictGetInt8",
        "dictGetInt16",
        "dictGetInt32",
        "dictGetInt64",
        "dictGetFloat32",
        "dictGetFloat64",
        "dictGetDate",
        "dictGetDateTime"
};
/** You can not completely remove GROUP BY. Because if there were no aggregate functions, then it turns out that there will be no aggregation.
  * Instead, leave `GROUP BY const`.
  * Next, see deleting the constants in the analyzeAggregation method.
  */
void appendUnusedGroupByColumn(ASTSelectQuery * select_query, const NameSet & source_columns)