Merge pull request #57063 from ClickHouse/fix-duplicate-storage-set-analyzer

Fix `Duplicate set` for StorageSet with analyzer.
This commit is contained in:
Alexey Milovidov 2023-11-22 13:36:44 +01:00 committed by GitHub
commit 54410f16c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -55,6 +55,9 @@ public:
{
/// Handle storage_set as ready set.
auto set_key = in_second_argument->getTreeHash();
if (sets.findStorage(set_key))
return;
sets.addFromStorage(set_key, storage_set->getSet());
}
else if (const auto * constant_node = in_second_argument->as<ConstantNode>())

View File

@ -19,3 +19,5 @@ abc
Hello
World
abc
Hello
Hello

View File

@ -1,5 +1,6 @@
DROP TABLE IF EXISTS set;
DROP TABLE IF EXISTS set2;
DROP TABLE IF EXISTS tab;
CREATE TABLE set (x String) ENGINE = Set;
@ -26,4 +27,9 @@ SELECT arrayJoin(['Hello', 'test', 'World', 'world', 'abc', 'xyz']) AS s WHERE s
RENAME TABLE set2 TO set;
SELECT arrayJoin(['Hello', 'test', 'World', 'world', 'abc', 'xyz']) AS s WHERE s IN set;
create table tab (x String) engine = MergeTree order by x as select 'Hello';
SELECT * FROM tab PREWHERE x IN (set) WHERE x IN (set) LIMIT 1 settings allow_experimental_analyzer=0;
SELECT * FROM tab PREWHERE x IN (set) WHERE x IN (set) LIMIT 1 settings allow_experimental_analyzer=1;
DROP TABLE tab;
DROP TABLE set;