This commit is contained in:
FFFFFFFHHHHHHH 2023-07-02 16:14:53 +08:00
parent 8c0463fdd4
commit 309fbc45a2
4 changed files with 55 additions and 46 deletions

View File

@ -1,32 +1,20 @@
0
0.5
1
0.67
1
0
0
0
1
0
0
0
0
0.5
1
0.67
0.5
0.5
0.5
0.5
1
1
1
1
1
1
1
1
0.33
0.2
1
1
[1] [1,2] 0.5
[1,2] [1,2] 1
[1,2,3] [1,2] 0.67
[1] [] 0
[1,2] [] 0
[1,2,3] [] 0
[] [1] 0
[] [1,2] 0
[] [1,2,3] 0
[1,2] [1] 0.5
[1,2] [1,2] 1
[1,2] [1,2,3] 0.67
[1] [1] 1
[1,2] [1,2] 1
[1,2,3] [1,2,3] 1
['a'] ['a','aa','aaa'] 0.33
[1,1.1,2.2] [2.2,3.3,444] 0.2
[1] [1] 1
[1,2] [1,2,3,4] 0.5
[[1,2],[3,4]] [[1,2],[3,5]] 0.33

View File

@ -1,26 +1,31 @@
drop table if exists array_jaccard_index;
create table array_jaccard_index (arr Array(UInt8)) engine=MergeTree partition by arr order by arr;
create table array_jaccard_index (arr Array(UInt8)) engine = MergeTree order by arr;
insert into array_jaccard_index values ([1,2,3]);
insert into array_jaccard_index values ([1,2]);
insert into array_jaccard_index values ([1]);
insert into array_jaccard_index values ([]);
select round(arrayJaccardIndex(arr, [1,2]), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex(arr, []), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([], arr), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([1,2], arr), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([1,2], [1,2,3,4]), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([], []), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex(arr, arr), 2) from array_jaccard_index order by arr;
select arr as arr_1, [1,2] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2) from array_jaccard_index order by arr;
drop table if exists array_jaccard_index;
select arr as arr_1, [] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex(['a'], ['a', 'aa', 'aaa']), 2);
select [] as arr_1, arr as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([1, 1.1, 2.2], [2.2, 3.3, 444]), 2);
select [1,2] as arr_1, arr as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([], []), 2);
select arr as arr_1, arr as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2) from array_jaccard_index order by arr;
select round(arrayJaccardIndex([toUInt16(1)], [toUInt32(1)]), 2);
drop table array_jaccard_index;
select ['a'] as arr_1, ['a', 'aa', 'aaa'] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2);
select [1, 1.1, 2.2] as arr_1, [2.2, 3.3, 444] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2);
select [toUInt16(1)] as arr_1, [toUInt32(1)] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2);
select [1,2] as arr_1, [1,2,3,4] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2);
select [[1,2], [3,4]] as arr_1, [[1,2], [3,5]] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2);

View File

@ -0,0 +1,2 @@
Code: 43
Code: 386

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CURDIR"/../shell_config.sh
echo ${CLICKHOUSE_CLIENT}
# Code: 43. DB::Exception: Received from localhost:9000. DB::Exception: array aggregate functions cannot be performed on two empty arrays: While processing arrayJaccardIndex([], []). (ILLEGAL_TYPE_OF_ARGUMENT)
$CLICKHOUSE_CLIENT -q "SELECT arrayJaccardIndex([], [])" |& grep -o "Code: 43"
# Code: 386. DB::Exception: Received from localhost:9000. DB::Exception: There is no subtype for types UInt8, String because some of them are String/FixedString and some of them are not: While processing [1, 2] AS arr_1, ['1', '2'] AS arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2). (NO_COMMON_TYPE)
$CLICKHOUSE_CLIENT -q "select [1,2] as arr_1, ['1','2'] as arr_2, round(arrayJaccardIndex(arr_1, arr_2), 2)" |& grep -o "Code: 386"