Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
2a6c7cda
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a6c7cda
编写于
6月 15, 2019
作者:
P
proller
提交者:
alexey-milovidov
6月 15, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CLICKHOUSE-4179 Fix function arrayEnumerateUniqRanked (#5622)
* wip * fix * clean
上级
e53a5a0c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
145 addition
and
3 deletion
+145
-3
dbms/src/Functions/arrayEnumerateRanked.h
dbms/src/Functions/arrayEnumerateRanked.h
+3
-1
dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference
...ts/queries/0_stateless/00909_arrayEnumerateUniq.reference
+53
-0
dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql
dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql
+84
-0
libs/libcommon/include/common/iostream_debug_helpers.h
libs/libcommon/include/common/iostream_debug_helpers.h
+5
-2
未找到文件。
dbms/src/Functions/arrayEnumerateRanked.h
浏览文件 @
2a6c7cda
...
...
@@ -11,6 +11,7 @@
#include <Common/ColumnsHashing.h>
#include <Common/HashTable/ClearableHashMap.h>
// for better debug: #include <Core/iostream_debug_helpers.h>
/** The function will enumerate distinct values of the passed multidimensional arrays looking inside at the specified depths.
* This is very unusual function made as a special order for Yandex.Metrica.
...
...
@@ -335,7 +336,8 @@ void FunctionArrayEnumerateRankedExtended<Derived>::executeMethodImpl(
if
(
prev_off
==
off
)
{
want_clear
=
true
;
++
indices_by_depth
[
0
];
if
(
arrays_depths
.
max_array_depth
>
1
)
++
indices_by_depth
[
0
];
for
(
ssize_t
depth
=
current_offset_depth
-
1
;
depth
>=
0
;
--
depth
)
{
...
...
dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.reference
浏览文件 @
2a6c7cda
...
...
@@ -171,6 +171,18 @@ arrayEnumerateUniq(a1, a2) =
2,a3,1,a4,2 [[1,1,1,2],[1,2,1],[1]]
2,a3,1,a4,2 [[1,1,1,2],[1,2,1],[1]]
---------END
a3,a4 1..n [[]]
a3,a4 1..n [[]]
a3,a4 1..n [[1,1]]
a3,a4 1..n [[1,1]]
a3,a4 1..n [[1,1]]
a3,a4 1..n [[1,1]]
a3,a4 1..1 [[]]
a3,a4 1..1 [[]]
a3,a4 1..1 [[1,2]]
a3,a4 1..1 [[3,4]]
a3,a4 1..1 [[1,2]]
a3,a4 1..1 [[3,4]]
---------BAD
[]
[]
...
...
@@ -225,3 +237,44 @@ arrayEnumerateUniq(a1, a2) =
[[],[],[1,2,1,4]] [[],[],[1,1,2,1]]
[[],[],[3,4,5,4]] [[],[],[1,1,1,2]]
--
a1,a2 n []
a1,a2 n []
a1,a2 n [1]
a1,a2 n [1]
a1,a2 1 []
a1,a2 1 []
a1,a2 1 [1]
a1,a2 1 [1]
a1,a2 n2 []
a1,a2 n2 []
a1,a2 n2 [1,1]
a1,a2 n2 [1,1]
a1,a2 n2 [1,1]
a1,a2 n2 [1,1]
a1,a2 12 []
a1,a2 12 []
a1,a2 12 [1,2]
a1,a2 12 [1,2]
a1,a2 12 [1,2]
a1,a2 12 [1,2]
1 2019-06-06 1 1 1 1 1 1 [] [] []
1 2019-06-06 -1 1 1 1 1 1 [] [] []
1 2019-06-06 1 1 1 2 1 1 [] [] []
1 2019-06-06 1 1 1 2 2 1 [1,2,3,4] [1001,1002,1003,1004] [1,1,1,1]
1 2019-06-06 1 2 1 1 3 1 [3,4,5] [2001,2002,2003] [1,1,1]
1 2019-06-06 1 3 2 1 4 1 [5,6] [3001,3002] [1,1]
1 2019-06-06 1 3 2 1 5 0 [] [] []
1 2019-06-06 1 4 2 1 5 1 [1,2] [1001,1002] [1,1]
1 2019-06-06 1 4 2 1 5 0 [1,2] [1002,1003] [1,1]
1 2019-06-06 1 4 2 1 6 0 [3] [2001] [1]
--
1 2019-06-06 1 1 1 1 1 1 [] [] []
1 2019-06-06 -1 1 1 1 1 1 [] [] []
1 2019-06-06 1 1 1 2 1 1 [] [] []
1 2019-06-06 1 1 1 2 2 1 [1,2,3,4] [1001,1002,1003,1004] [1,1,1,1]
1 2019-06-06 1 2 1 1 3 1 [3,4,5] [2001,2002,2003] [1,1,1]
1 2019-06-06 1 3 2 1 4 1 [5,6] [3001,3002] [1,1]
1 2019-06-06 1 3 2 1 5 0 [] [] []
1 2019-06-06 1 4 2 1 5 1 [1,2] [1001,1002] [1,1]
1 2019-06-06 1 4 2 1 5 0 [1,2] [1002,1003] [1,1]
1 2019-06-06 1 4 2 1 6 0 [3] [2001] [1]
dbms/tests/queries/0_stateless/00909_arrayEnumerateUniq.sql
浏览文件 @
2a6c7cda
-- env SQL_FUZZY_FUNCTIONS=arrayEnumerateUniqRanked,arrayEnumerateDenseRanked SQL_FUZZY_RUNS=1000 clickhouse-test fuzzy
SELECT
arrayEnumerateUniq
(
[
1
,
1
,
2
,
2
,
1
,
1
],
[
1
,
2
,
1
,
2
,
2
,
2
]);
SELECT
arrayEnumerateUniqRanked
(
1
,
[
1
,
1
,
2
,
2
,
1
,
1
],
1
,
[
1
,
2
,
1
,
2
,
2
,
2
],
1
);
...
...
@@ -140,6 +141,16 @@ SELECT '2,a3,1,a4,2', arrayEnumerateUniqRanked(2,a3,1,a4,2) FROM arrays_test ORD
select
'---------END'
;
DROP
TABLE
arrays_test
;
CREATE
TABLE
arrays_test
(
a3
Array
(
Array
(
UInt8
)),
a4
Array
(
Array
(
UInt32
))
)
ENGINE
=
Memory
;
INSERT
INTO
arrays_test
VALUES
([[]],
[[]]),
([[
1
,
2
]],
[[
3
,
4
]]),
([[
5
,
6
]],
[[
7
,
8
]]),
([[]],
[[]]),
([[
9
,
10
]],
[[
11
,
12
]]),
([[
13
,
14
]],
[[
15
,
16
]]);
SELECT
'a3,a4 1..n'
,
arrayEnumerateUniqRanked
(
a3
,
a4
)
FROM
arrays_test
ORDER
BY
a3
,
a4
;
TRUNCATE
TABLE
arrays_test
;
INSERT
INTO
arrays_test
VALUES
([[]],
[[]]),
([[
1
,
1
]],
[[
1
,
1
]]),
([[
1
,
1
]],
[[
1
,
1
]]),
([[]],
[[]]),
([[
1
,
1
]],
[[
1
,
1
]]),
([[
1
,
1
]],
[[
1
,
1
]]);
SELECT
'a3,a4 1..1'
,
arrayEnumerateUniqRanked
(
a3
,
a4
)
FROM
arrays_test
ORDER
BY
a3
,
a4
;
DROP
TABLE
arrays_test
;
select
'---------BAD'
;
SELECT
arrayEnumerateUniqRanked
();
-- { serverError 42 }
SELECT
arrayEnumerateUniqRanked
([]);
...
...
@@ -221,3 +232,76 @@ SELECT a, arrayEnumerateUniqRanked(a) FROM ( SELECT * FROM ( SELECT [[], [], [1,
select
'-- '
;
SELECT
a
,
arrayEnumerateUniqRanked
(
a
)
FROM
(
SELECT
*
FROM
(
SELECT
[[],
[],
[
1
,
2
,
1
,
4
]]
AS
a
UNION
ALL
SELECT
[[],
[],
[
3
,
4
,
5
,
4
]]
AS
a
)
ORDER
BY
a
ASC
);
select
'-- '
;
DROP
TABLE
IF
EXISTS
arrays_test
;
CREATE
TABLE
arrays_test
(
a1
Array
(
UInt8
),
a2
Array
(
UInt32
)
)
ENGINE
=
Memory
;
INSERT
INTO
arrays_test
VALUES
([],
[]),([
10
],
[
11
]),
([],
[]),
([
12
],
[
13
]);
SELECT
'a1,a2 n'
,
arrayEnumerateUniqRanked
(
a1
,
a2
)
FROM
arrays_test
ORDER
BY
a1
,
a2
;
TRUNCATE
TABLE
arrays_test
;
INSERT
INTO
arrays_test
VALUES
([],
[]),([
1
],
[
1
]),
([],
[]),
([
1
],
[
1
]);
SELECT
'a1,a2 1'
,
arrayEnumerateUniqRanked
(
a1
,
a2
)
FROM
arrays_test
ORDER
BY
a1
,
a2
;
TRUNCATE
TABLE
arrays_test
;
INSERT
INTO
arrays_test
VALUES
([],
[]),
([
1
,
2
],
[
3
,
4
]),
([
5
,
6
],
[
7
,
8
]),
([],
[]),
([
9
,
10
],
[
11
,
12
]),
([
13
,
14
],
[
15
,
16
]);
SELECT
'a1,a2 n2'
,
arrayEnumerateUniqRanked
(
a1
,
a2
)
FROM
arrays_test
ORDER
BY
a1
,
a2
;
TRUNCATE
TABLE
arrays_test
;
INSERT
INTO
arrays_test
VALUES
([],
[]),
([
1
,
1
],
[
1
,
1
]),
([
1
,
1
],
[
1
,
1
]),
([],
[]),
([
1
,
1
],
[
1
,
1
]),
([
1
,
1
],
[
1
,
1
]);
SELECT
'a1,a2 12'
,
arrayEnumerateUniqRanked
(
a1
,
a2
)
FROM
arrays_test
ORDER
BY
a1
,
a2
;
DROP
TABLE
arrays_test
;
DROP
TABLE
IF
EXISTS
arr_tests_visits
;
CREATE
TABLE
arr_tests_visits
(
CounterID
UInt32
,
StartDate
Date
,
Sign
Int8
,
VisitID
UInt64
,
UserID
UInt64
,
VisitVersion
UInt16
,
`Test.BannerID`
Array
(
UInt64
),
`Test.Load`
Array
(
UInt8
),
`Test.PuidKey`
Array
(
Array
(
UInt8
)),
`Test.PuidVal`
Array
(
Array
(
UInt32
))
)
ENGINE
=
MergeTree
()
PARTITION
BY
toMonday
(
StartDate
)
ORDER
BY
(
CounterID
,
StartDate
,
intHash32
(
UserID
),
VisitID
)
SAMPLE
BY
intHash32
(
UserID
)
SETTINGS
index_granularity
=
8192
;
truncate
table
arr_tests_visits
;
insert
into
arr_tests_visits
(
CounterID
,
StartDate
,
Sign
,
VisitID
,
UserID
,
VisitVersion
,
`Test.BannerID`
,
`Test.Load`
,
`Test.PuidKey`
,
`Test.PuidVal`
)
values
(
1
,
toDate
(
'2019-06-06'
),
1
,
1
,
1
,
1
,
[
1
],
[
1
],
[[]],
[[]]),
(
1
,
toDate
(
'2019-06-06'
),
-
1
,
1
,
1
,
1
,
[
1
],
[
1
],
[[]],
[[]]),
(
1
,
toDate
(
'2019-06-06'
),
1
,
1
,
1
,
2
,
[
1
,
2
],
[
1
,
1
],
[[],[
1
,
2
,
3
,
4
]],
[[],[
1001
,
1002
,
1003
,
1004
]]),
(
1
,
toDate
(
'2019-06-06'
),
1
,
2
,
1
,
1
,
[
3
],
[
1
],
[[
3
,
4
,
5
]],
[[
2001
,
2002
,
2003
]]),
(
1
,
toDate
(
'2019-06-06'
),
1
,
3
,
2
,
1
,
[
4
,
5
],
[
1
,
0
],
[[
5
,
6
],[]],
[[
3001
,
3002
],[]]),
(
1
,
toDate
(
'2019-06-06'
),
1
,
4
,
2
,
1
,
[
5
,
5
,
6
],
[
1
,
0
,
0
],
[[
1
,
2
],
[
1
,
2
],
[
3
]],
[[
1001
,
1002
],[
1002
,
1003
],
[
2001
]]);
select
CounterID
,
StartDate
,
Sign
,
VisitID
,
UserID
,
VisitVersion
,
BannerID
,
Load
,
PuidKeyArr
,
PuidValArr
,
arrayEnumerateUniqRanked
(
PuidKeyArr
,
PuidValArr
)
as
uniqTestPuid
from
arr_tests_visits
array
join
Test
.
BannerID
as
BannerID
,
Test
.
Load
as
Load
,
Test
.
PuidKey
as
PuidKeyArr
,
Test
.
PuidVal
as
PuidValArr
;
select
'--'
;
SELECT
CounterID
,
StartDate
,
Sign
,
VisitID
,
UserID
,
VisitVersion
,
BannerID
,
Load
,
PuidKeyArr
,
PuidValArr
,
arrayEnumerateUniqRanked
(
PuidKeyArr
,
PuidValArr
)
AS
uniqTestPuid
FROM
arr_tests_visits
ARRAY
JOIN
Test
.
BannerID
AS
BannerID
,
Test
.
Load
AS
Load
,
Test
.
PuidKey
AS
PuidKeyArr
,
Test
.
PuidVal
AS
PuidValArr
;
DROP
TABLE
arr_tests_visits
;
libs/libcommon/include/common/iostream_debug_helpers.h
浏览文件 @
2a6c7cda
...
...
@@ -150,11 +150,14 @@ Out & dump(Out & out, const char * name, T && x)
#define DUMP4(V1, V2, V3, V4) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPTAIL } while(0)
#define DUMP5(V1, V2, V3, V4, V5) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPVAR(V5) DUMPTAIL } while(0)
#define DUMP6(V1, V2, V3, V4, V5, V6) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPVAR(V5) DUMPVAR(V6) DUMPTAIL } while(0)
#define DUMP7(V1, V2, V3, V4, V5, V6, V7) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPVAR(V5) DUMPVAR(V6) DUMPVAR(V7) DUMPTAIL } while(0)
#define DUMP8(V1, V2, V3, V4, V5, V6, V7, V8) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPVAR(V5) DUMPVAR(V6) DUMPVAR(V7) DUMPVAR(V8) DUMPTAIL } while(0)
#define DUMP9(V1, V2, V3, V4, V5, V6, V7, V8, V9) do { DUMPHEAD DUMPVAR(V1) DUMPVAR(V2) DUMPVAR(V3) DUMPVAR(V4) DUMPVAR(V5) DUMPVAR(V6) DUMPVAR(V7) DUMPVAR(V8) DUMPVAR(V9) DUMPTAIL } while(0)
/// https://groups.google.com/forum/#!searchin/kona-dev/variadic$20macro%7Csort:date/kona-dev/XMA-lDOqtlI/GCzdfZsD41sJ
#define VA_NUM_ARGS_IMPL(x1, x2, x3, x4, x5, x6, N, ...) N
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 6, 5, 4, 3, 2, 1)
#define VA_NUM_ARGS_IMPL(x1, x2, x3, x4, x5, x6,
x7, x8, x9,
N, ...) N
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__,
9, 8, 7,
6, 5, 4, 3, 2, 1)
#define MAKE_VAR_MACRO_IMPL_CONCAT(PREFIX, NUM_ARGS) PREFIX ## NUM_ARGS
#define MAKE_VAR_MACRO_IMPL(PREFIX, NUM_ARGS) MAKE_VAR_MACRO_IMPL_CONCAT(PREFIX, NUM_ARGS)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录