pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/Dwrite/ClickHouse/commit/7de445a41f77546802c12518693d64bfa8edd5b3

69660fa.css" /> Some fixups · Dwrite/ClickHouse@7de445a · GitHub
Skip to content

Commit 7de445a

Browse files
committed
Some fixups
1 parent 0dd39b7 commit 7de445a

4 files changed

Lines changed: 51 additions & 30 deletions

File tree

src/Functions/array/arrayIntersect.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ ColumnPtr FunctionArrayIntersect<Mode>::execute(const UnpackedArrays & arrays, M
633633
}
634634
if (!current_has_nullable)
635635
all_has_nullable = false;
636-
else
636+
else
637637
null_amount++;
638638

639639
}
@@ -649,9 +649,7 @@ ColumnPtr FunctionArrayIntersect<Mode>::execute(const UnpackedArrays & arrays, M
649649
{
650650
typename Map::LookupResult pair = map.find(p.getKey());
651651
if (pair && pair->getMapped() >= 1)
652-
{
653652
insertElement<Map, ColumnType, is_numeric_column>(pair, result_offset, result_data, null_map, use_null_map);
654-
}
655653
}
656654
if (null_amount > 0 && !null_added)
657655
{
@@ -667,10 +665,8 @@ ColumnPtr FunctionArrayIntersect<Mode>::execute(const UnpackedArrays & arrays, M
667665
for (auto & p : map)
668666
{
669667
typename Map::LookupResult pair = map.find(p.getKey());
670-
if (pair && pair->getMapped() > 0 && pair->getMapped() < args)
671-
{
668+
if (pair && pair->getMapped() >= 1 && pair->getMapped() < args)
672669
insertElement<Map, ColumnType, is_numeric_column>(pair, result_offset, result_data, null_map, use_null_map);
673-
}
674670
}
675671
if (null_amount > 0 && null_amount < args && !null_added)
676672
{
@@ -710,9 +706,7 @@ ColumnPtr FunctionArrayIntersect<Mode>::execute(const UnpackedArrays & arrays, M
710706
continue;
711707
}
712708
else if constexpr (is_numeric_column)
713-
{
714709
pair = map.find(columns[0]->getElement(i));
715-
}
716710
else if constexpr (std::is_same_v<ColumnType, ColumnString> || std::is_same_v<ColumnType, ColumnFixedString>)
717711
pair = map.find(columns[0]->getDataAt(i));
718712
else
@@ -730,9 +724,7 @@ ColumnPtr FunctionArrayIntersect<Mode>::execute(const UnpackedArrays & arrays, M
730724
// Add the value if all arrays have the value for intersect
731725
// or if there was at least one occurrence in all of the arrays for union
732726
if (pair && pair->getMapped() == args)
733-
{
734727
insertElement<Map, ColumnType, is_numeric_column>(pair, result_offset, result_data, null_map, use_null_map);
735-
}
736728
}
737729
}
738730

@@ -771,6 +763,7 @@ void FunctionArrayIntersect<Mode>::insertElement(typename Map::LookupResult & pa
771763
using ArrayIntersect = FunctionArrayIntersect<ArrayModeIntersect>;
772764
using ArrayUnion = FunctionArrayIntersect<ArrayModeUnion>;
773765
using ArraySymmetricDifference = FunctionArrayIntersect<ArrayModeSymmetricDifference>;
766+
774767
REGISTER_FUNCTION(ArrayIntersect)
775768
{
776769
factory.registerFunction<ArrayIntersect>();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Negative tests
2+
Const arguments
3+
[]
4+
[]
5+
[2,3]
6+
['b','c']
7+
[3,NULL]
8+
[1,3]
9+
[]
10+
[]
11+
[]
12+
[2,3]
13+
Array(Tuple(Nullable(UInt8), Array(Nullable(String))))
14+
Non-const arguments
15+
[(2,['c','']),(NULL,['c'])]
16+
[(3,['g','']),(NULL,['f'])]
17+
[(4,['j','']),(NULL,['i'])]
18+
[(5,['m','']),(NULL,['l'])]
19+
[]
20+
[]
21+
[]
22+
[]
Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
DROP TABLE IF EXISTS array_symmetric_difference;
2-
3-
CREATE TABLE IF NOT EXISTS array_symmetric_difference (
4-
id UInt8,
5-
arr_tpl_1 Array( Tuple(Nullable(Int32),Array(String)) ),
6-
arr_tpl_2 Array( Tuple(Nullable(Int32),Array(String)) ),
7-
arr_lc_str_1 Array( LowCardinality(String) ),
8-
arr_lc_str_2 Array( LowCardinality(String) )
9-
) ENGINE = MergeTree ORDER BY id;
10-
11-
INSERT INTO array_symmetric_difference VALUES (1, [(1, ['a', 'b']), (Null, ['c'])], [(2, ['c', Null]), (1, ['a', 'b'])], ['a', 'b', 'c'], ['c', 'a', 'b']);
12-
INSERT INTO array_symmetric_difference VALUES (2, [(2, ['d', 'e']), (Null, ['f'])], [(3, ['g', Null]), (2, ['d', 'e'])], ['d', 'e', 'f'], ['f', 'd', 'e']);
13-
INSERT INTO array_symmetric_difference VALUES (3, [(3, ['g', 'h']), (Null, ['i'])], [(4, ['j', Null]), (3, ['g', 'h'])], ['g', 'h', 'i'], ['i', 'g', 'h']);
14-
INSERT INTO array_symmetric_difference VALUES (4, [(4, ['j', 'k']), (Null, ['l'])], [(5, ['m', Null]), (4, ['j', 'k'])], ['j', 'k', 'l'], ['l', 'j', 'k']);
15-
16-
-- negative tests
1+
SELECT 'Negative tests';
172
SELECT arraySymmetricDifference(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
183
SELECT arraySymmetricDifference(1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
194
SELECT arraySymmetricDifference(1, 2); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
205
SELECT arraySymmetricDifference(1, [1, 2]); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
216
SELECT arraySymmetricDifference([1, 2], 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
227

8+
SELECT 'Const arguments';
239
SELECT arraySort(arraySymmetricDifference([]));
2410
SELECT arraySort(arraySymmetricDifference([1, 2]));
2511
SELECT arraySort(arraySymmetricDifference([1, 2], [1, 3]));
2612
SELECT arraySort(arraySymmetricDifference(['a', 'b'], ['a', 'c']));
2713
SELECT arraySort(arraySymmetricDifference([1, NULL], [1, 3]));
2814
SELECT arraySort(arraySymmetricDifference([1, NULL], [NULL, 3]));
29-
SELECT arraySort(arraySymmetricDifference([1, 2], [1, 3]));
15+
SELECT arraySort(arraySymmetricDifference([1, 1], [1, 1]));
16+
SELECT arraySort(arraySymmetricDifference([1, 2], [1, 2]));
3017
SELECT arraySort(arraySymmetricDifference([1, 2], [1, 2], [1, 2]));
3118
SELECT arraySort(arraySymmetricDifference([1, 2], [1, 2], [1, 3]));
19+
3220
SELECT toTypeName(arraySymmetricDifference([(1, ['a', 'b']), (Null, ['c'])], [(2, ['c', Null]), (1, ['a', 'b'])]));
21+
22+
SELECT 'Non-const arguments';
23+
24+
DROP TABLE IF EXISTS tab;
25+
26+
CREATE TABLE tab (
27+
id UInt8,
28+
array_tuple1 Array( Tuple(Nullable(Int32),Array(String)) ),
29+
array_tuple2 Array( Tuple(Nullable(Int32),Array(String)) ),
30+
array_lowcardinality_string1 Array( LowCardinality(String) ),
31+
array_lowcardinality_string2 Array( LowCardinality(String) )
32+
) ENGINE = MergeTree ORDER BY id;
33+
34+
INSERT INTO tab VALUES (1, [(1, ['a', 'b']), (Null, ['c'])], [(2, ['c', Null]), (1, ['a', 'b'])], ['a', 'b', 'c'], ['c', 'a', 'b']);
35+
INSERT INTO tab VALUES (2, [(2, ['d', 'e']), (Null, ['f'])], [(3, ['g', Null]), (2, ['d', 'e'])], ['d', 'e', 'f'], ['f', 'd', 'e']);
36+
INSERT INTO tab VALUES (3, [(3, ['g', 'h']), (Null, ['i'])], [(4, ['j', Null]), (3, ['g', 'h'])], ['g', 'h', 'i'], ['i', 'g', 'h']);
37+
INSERT INTO tab VALUES (4, [(4, ['j', 'k']), (Null, ['l'])], [(5, ['m', Null]), (4, ['j', 'k'])], ['j', 'k', 'l'], ['l', 'j', 'k']);
38+
3339
--
34-
SELECT arraySort(arraySymmetricDifference(arr_tpl_1, arr_tpl_2)) FROM array_symmetric_difference ORDER BY id;
35-
SELECT arraySort(arraySymmetricDifference(arr_lc_str_1, arr_lc_str_2)) FROM array_symmetric_difference ORDER BY id;
40+
SELECT arraySort(arraySymmetricDifference(array_tuple1, array_tuple2)) FROM tab ORDER BY id;
41+
SELECT arraySort(arraySymmetricDifference(array_lowcardinality_string1, array_lowcardinality_string2)) FROM tab ORDER BY id;
3642

37-
DROP TABLE array_symmetric_difference;
43+
DROP TABLE tab;

tests/queries/0_stateless/03357_arraySymmetricDifference.stdout-e

Whitespace-only changes.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy