Merge pull request #65081 from ClickHouse/fix-64849

Fix infinite query duration in case of cyclic aliases.
This commit is contained in:
Nikolai Kochetov 2024-06-11 17:03:52 +00:00 committed by GitHub
commit fe4c4db6ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -75,7 +75,12 @@ struct ScopeAliases
if (jt == transitive_aliases.end())
return {};
key = &(getKey(jt->second, find_option));
const auto & new_key = getKey(jt->second, find_option);
/// Ignore potential cyclic aliases.
if (new_key == *key)
return {};
key = &new_key;
it = alias_map.find(*key);
}

View File

@ -1,2 +1,3 @@
1 2 3
1 5
300

View File

@ -30,3 +30,7 @@ WHERE (time_stamp_utc >= toDateTime('2024-04-25 00:00:00')) AND (time_stamp_utc
GROUP BY time_stamp_utc
ORDER BY Impressions DESC
LIMIT 1000;
drop table test_table;
create table test_table engine MergeTree order by sum as select 100 as sum union all select 200 as sum;
select sum as sum from (select sum(sum) as sum from test_table);