Merge pull request #13868 from ClickHouse/stratify-array-compact-nan

Stratify nans comparison in arrayCompact function
This commit is contained in:
alexey-milovidov 2020-08-19 11:53:58 +03:00 committed by GitHub
commit 6d72777b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@
#include <DataTypes/DataTypesDecimal.h>
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnDecimal.h>
#include <Common/HashTable/HashTable.h>
#include <Functions/array/FunctionArrayMapped.h>
#include <Functions/FunctionFactory.h>
@ -67,7 +68,7 @@ struct ArrayCompactImpl
++res_pos;
for (; src_pos < src_offset; ++src_pos)
{
if (src_values[src_pos] != src_values[src_pos - 1])
if (!bitEquals(src_values[src_pos], src_values[src_pos - 1]))
{
res_values[res_pos] = src_values[src_pos];
++res_pos;

View File

@ -1,7 +1,8 @@
[]
[1,nan,2]
[1,nan,nan,2]
[1,nan,nan,nan,2]
[1,NULL,2]
[1,NULL,nan,2]
['hello','','world']
[[[]],[[],[]],[[]]]
[]

View File

@ -2,6 +2,7 @@ SELECT arrayCompact([]);
SELECT arrayCompact([1, 1, nan, nan, 2, 2, 2]);
SELECT arrayCompact([1, 1, nan, nan, -nan, 2, 2, 2]);
SELECT arrayCompact([1, 1, NULL, NULL, 2, 2, 2]);
SELECT arrayCompact([1, 1, NULL, NULL, nan, nan, 2, 2, 2]);
SELECT arrayCompact(['hello', '', '', '', 'world', 'world']);
SELECT arrayCompact([[[]], [[], []], [[], []], [[]]]);
SELECT arrayCompact(x -> toString(intDiv(x, 3)), range(number)) FROM numbers(10);