Stratify nans comparison in arrayCompact function

This commit is contained in:
Alexey Milovidov 2020-08-18 22:16:53 +03:00
parent 793fd5bfb1
commit acf312467e
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);