From e8a8da1a4fe30d417cf1c48bc26d941b41edde14 Mon Sep 17 00:00:00 2001 From: Nikolai Kochetov Date: Mon, 1 Apr 2019 16:27:07 +0300 Subject: [PATCH] Fix array intersect. --- dbms/src/Functions/arrayIntersect.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbms/src/Functions/arrayIntersect.cpp b/dbms/src/Functions/arrayIntersect.cpp index 38de722732..93c588fc4f 100644 --- a/dbms/src/Functions/arrayIntersect.cpp +++ b/dbms/src/Functions/arrayIntersect.cpp @@ -432,15 +432,20 @@ ColumnPtr FunctionArrayIntersect::execute(const UnpackedArrays & arrays, Mutable current_has_nullable = true; else { + typename Map::mapped_type * value = nullptr; + if constexpr (is_numeric_column) - ++map[columns[arg]->getElement(i)]; + value = &map[columns[arg]->getElement(i)]; else if constexpr (std::is_same::value || std::is_same::value) - ++map[columns[arg]->getDataAt(i)]; + value = &map[columns[arg]->getDataAt(i)]; else { const char * data = nullptr; - ++map[columns[arg]->serializeValueIntoArena(i, arena, data)]; + value = &map[columns[arg]->serializeValueIntoArena(i, arena, data)]; } + + if (*value == arg) + ++(*value); } } -- GitLab