**How to reproduce**
Tested on Clickhouse server version 20.4.6 revision 54434.

Given setup:
```sql
create table main(date Date, user UInt32, data UInt32) engine=Memory();
create table j1(date Date, thing UInt32) engine=Memory();
create table j2(date Date, thing UInt32) engine=Memory();
```

The following query works:
```sql
select
    main.date,
    user
from main
join j1 on main.user=j1.thing
```

But the following query fails:
```sql
select
    main.date,
    user
from main
join j1 on main.user=j1.thing
join j2 on main.data=j2.thing
```
With:
```
DB::Exception: Missing columns: 'user' while processing query: 'SELECT `--main.date` AS `main.date`, user FROM (SELECT * FROM main INNER JOIN j1 ON `--main.user` = `--j1.thing`) AS `--.s` ALL INNER JOIN (SELECT * FROM j2) AS j2 ON `--main.data` = thing', required columns: '--main.date' '--main.data' 'user' 'thing', source columns: '--j1.thing' 'j1.date' '--main.data' '--main.user' '--main.date', joined columns: 'date' 'thing'.
```

The query does work if I explicitly change `user` to `main.user` in the SELECT clause.

Since `user` is not an ambiguous column and joining `j2` doesn't have anthing to do with the `user` column, I'd expect my query to not break when adding the second join.
M(SettingString, format_custom_row_before_delimiter, "", "Delimiter before field of the first column (for CustomSeparated format)", 0) \
    M(SettingString, format_custom_row_after_delimiter, "\n", "Delimiter after field of the last column (for CustomSeparated format)", 0) \
    M(SettingString, format_custom_row_between_delimiter, "", "Delimiter between rows (for CustomSeparated format)", 0) \
    M(SettingString, format_custom_result_before_delimiter, "", "Prefix before result set (for CustomSeparated format)", 0) \
    M(SettingString, format_custom_result_after_delimiter, "", "Suffix after result set (for CustomSeparated format)", 0) \
    \
    M(SettingString, format_regexp, "", "Regular expression (for Regexp format)", 0) \
    M(SettingString, format_regexp_escaping_rule, "Escaped", "Field escaping rule (for Regexp format)", 0) \
    M(SettingBool, format_regexp_skip_unmatched, false, "Skip lines unmatched by regular expression (for Regexp format", 0) \
    \
    M(SettingBool, output_format_enable_streaming, false, "Enable streaming in output formats that support it.", 0) \
    M(SettingBool, output_format_write_statistics, true, "Write statistics about read rows, bytes, time elapsed in suitable output formats.", 0)
    #define LIST_OF_SETTINGS(M)    \
        COMMON_SETTINGS(M)         \
        FORMAT_FACTORY_SETTINGS(M)
    DECLARE_SETTINGS_COLLECTION(LIST_OF_SETTINGS)
    /** Set multiple settings from "profile" (in server configuration file (users.xml), profiles contain groups of multiple settings).
     * The profile can also be set using the `set` functions, like the profile setting.
     */
    void setProfile(const String & profile_name, const Poco::Util::AbstractConfiguration & config);
    /// 
    void loadSettingsFromConfig(const String & path, const Poco::Util::AbstractConfiguration & config);
    /// 
    void dumpToArrayColumns(IColumn * column_names, IColumn * column_values, bool changed_only = true);
    /// 
    /// 
    void addProgramOptions(boost::program_options::options_description & options);
};
}