From 1989b50166760e2aba201c1aa50f7aebce780cb6 Mon Sep 17 00:00:00 2001 From: alexey-milovidov Date: Fri, 13 Sep 2019 08:57:30 +0300 Subject: [PATCH] Merge pull request #6928 from proller/fix27 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CLICKHOUSE-4652 Another fix for АrrayEnumerateUniqRanked with empty arrays (cherry picked from commit ba40858094e06358d5d76f008059940ef9808823) --- dbms/src/Functions/array/arrayEnumerateRanked.h | 5 +---- .../queries/0_stateless/00909_arrayEnumerateUniq.reference | 3 +++ dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dbms/src/Functions/array/arrayEnumerateRanked.h b/dbms/src/Functions/array/arrayEnumerateRanked.h index a1019ba83bf..de7656b70da 100644 --- a/dbms/src/Functions/array/arrayEnumerateRanked.h +++ b/dbms/src/Functions/array/arrayEnumerateRanked.h @@ -336,10 +336,6 @@ void FunctionArrayEnumerateRankedExtended::executeMethodImpl( /// Skipping offsets if no data in this array if (prev_off == off) { - - if (depth_to_look > 2) - want_clear = true; - if (depth_to_look >= 2) { /// Advance to the next element of the parent array. @@ -357,6 +353,7 @@ void FunctionArrayEnumerateRankedExtended::executeMethodImpl( { last_offset_by_depth[depth] = (*offsets_by_depth[depth])[current_offset_n_by_depth[depth]]; ++current_offset_n_by_depth[depth]; + want_clear = true; } else { diff --git a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference index 595dcdf3803..6f9a0bb9ea3 100644 --- a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference +++ b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference @@ -284,3 +284,6 @@ a1,a2 12 [1,2] [[1],[],[2],[],[3],[],[4],[],[5],[],[6],[],[7],[],[8],[],[9]] [[],[1],[],[2],[],[3],[],[4],[],[5],[],[6],[],[7],[],[8]] [[1],[2],[],[3]] +-- empty corner +[[],[1],[]] [[],[1],[]] +[[1]] [[1]] diff --git a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql index 9cf82a368d6..33097c99272 100644 --- a/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql +++ b/dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql @@ -313,3 +313,6 @@ SELECT arrayEnumerateUniqRanked([[1], [], [1]]); SELECT arrayEnumerateUniqRanked([[1], [], [1], [], [1], [], [1], [], [1], [], [1], [], [1], [], [1], [], [1]]); SELECT arrayEnumerateUniqRanked([[], [1], [], [1], [], [1], [], [1], [], [1], [], [1], [], [1], [], [1]]); SELECT arrayEnumerateUniqRanked([[1], [1], [], [1]]); + +select '-- empty corner'; +SELECT a, arrayEnumerateUniqRanked(a) FROM ( SELECT * FROM ( SELECT [[],[1],[]] AS a UNION ALL SELECT [[1]] AS a ) ORDER BY a ASC );