Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
a1f2b9ae
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,发现更多精彩内容 >>
提交
a1f2b9ae
编写于
8月 31, 2018
作者:
Z
zhang2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ISSUES-2973 support nested json struct for visitParamExtractRaw
上级
918d17ff
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
26 deletion
+28
-26
dbms/src/Functions/FunctionsVisitParam.h
dbms/src/Functions/FunctionsVisitParam.h
+25
-23
dbms/tests/performance/functions_json/visit_param_extract_raw.xml
...ts/performance/functions_json/visit_param_extract_raw.xml
+1
-1
dbms/tests/queries/0_stateless/00539_functions_for_working_with_json.reference
...stateless/00539_functions_for_working_with_json.reference
+1
-1
dbms/tests/queries/0_stateless/00539_functions_for_working_with_json.sql
...ies/0_stateless/00539_functions_for_working_with_json.sql
+1
-1
未找到文件。
dbms/src/Functions/FunctionsVisitParam.h
浏览文件 @
a1f2b9ae
...
...
@@ -87,45 +87,47 @@ struct ExtractBool
struct
ExtractRaw
{
inline
static
void
skipAfterQuotationIfNeed
(
const
UInt8
*&
pos
,
const
UInt8
*
end
,
ColumnString
::
Chars_t
&
res_data
)
{
if
(
pos
+
1
<
end
&&
pos
[
1
]
==
'"'
)
{
res_data
.
push_back
(
*
pos
);
++
pos
;
}
}
static
constexpr
size_t
bytes_on_stack
=
64
;
using
ExpectChars
=
PODArray
<
char
,
bytes_on_stack
,
AllocatorWithStackMemory
<
Allocator
<
false
>
,
bytes_on_stack
>>
;
static
void
extract
(
const
UInt8
*
pos
,
const
UInt8
*
end
,
ColumnString
::
Chars_t
&
res_data
)
{
std
::
vector
<
char
>
expect_end
;
ExpectChars
expects_end
;
UInt8
current_expect_end
=
0
;
for
(;
pos
!=
end
;
++
pos
)
for
(
auto
extract_begin
=
pos
;
pos
!=
end
;
++
pos
)
{
if
(
!
expect_end
.
empty
()
&&
*
pos
==
expect_end
.
back
())
expect_end
.
pop_back
();
if
(
*
pos
==
current_expect_end
)
{
expects_end
.
pop_back
();
current_expect_end
=
(
UInt8
)
(
expects_end
.
empty
()
?
0
:
expects_end
.
back
());
}
else
{
switch
(
*
pos
)
switch
(
*
pos
)
{
case
'['
:
expect
_end
.
push_back
(
']'
);
case
'['
:
expect
s_end
.
push_back
((
current_expect_end
=
']'
));
break
;
case
'{'
:
expect
_end
.
push_back
(
'}'
);
case
'{'
:
expect
s_end
.
push_back
((
current_expect_end
=
'}'
));
break
;
case
'"'
:
expect
_end
.
push_back
(
'"'
);
case
'"'
:
expect
s_end
.
push_back
((
current_expect_end
=
'"'
));
break
;
case
'\\'
:
skipAfterQuotationIfNeed
(
pos
,
end
,
res_data
);
case
'\\'
:
/// skip backslash
if
(
pos
+
1
<
end
&&
pos
[
1
]
==
'"'
)
pos
++
;
break
;
default:
if
(
expect_end
.
empty
()
&&
(
*
pos
==
','
||
*
pos
==
'}'
))
if
(
!
current_expect_end
&&
(
*
pos
==
','
||
*
pos
==
'}'
))
{
res_data
.
insert
(
extract_begin
,
pos
);
return
;
}
}
}
res_data
.
push_back
(
*
pos
);
}
}
};
...
...
dbms/tests/performance/functions_json/visit_param_extract_raw.xml
浏览文件 @
a1f2b9ae
...
...
@@ -27,5 +27,5 @@
</substitution>
</substitutions>
<query>
SELECT count() FROM system.numbers WHERE NOT ignore(visitParamExtractRaw(
{param}
, 'myparam'))
</query>
<query>
SELECT count() FROM system.numbers WHERE NOT ignore(visitParamExtractRaw(
materialize({param})
, 'myparam'))
</query>
</test>
dbms/tests/queries/0_stateless/00539_functions_for_working_with_json.reference
浏览文件 @
a1f2b9ae
...
...
@@ -9,5 +9,5 @@ test"string
"test_string"
"test\\"string"
"test\\"string"
[
1,2,3
]
[
"]", "2", "3"
]
{"nested" : [1,2,3]}
dbms/tests/queries/0_stateless/00539_functions_for_working_with_json.sql
浏览文件 @
a1f2b9ae
...
...
@@ -11,5 +11,5 @@ SELECT visitParamExtractRaw('{"myparam":"test_string"}', 'myparam');
SELECT
visitParamExtractRaw
(
'{"myparam": "test_string"}'
,
'myparam'
);
SELECT
visitParamExtractRaw
(
'{"myparam": "test
\\
"string"}'
,
'myparam'
);
SELECT
visitParamExtractRaw
(
'{"myparam": "test
\\
"string", "other":123}'
,
'myparam'
);
SELECT
visitParamExtractRaw
(
'{"myparam": [
1,2,3
], "other":123}'
,
'myparam'
);
SELECT
visitParamExtractRaw
(
'{"myparam": [
"]", "2", "3"
], "other":123}'
,
'myparam'
);
SELECT
visitParamExtractRaw
(
'{"myparam": {"nested" : [1,2,3]}, "other":123}'
,
'myparam'
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录