Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
ca1484ae
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,发现更多精彩内容 >>
提交
ca1484ae
编写于
2月 13, 2019
作者:
N
Nikita Vasilev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set exactly one arg
上级
a27c61b0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
17 deletion
+14
-17
dbms/src/Storages/MergeTree/MergeTreeSetSkippingIndex.cpp
dbms/src/Storages/MergeTree/MergeTreeSetSkippingIndex.cpp
+11
-14
dbms/tests/queries/0_stateless/00838_unique_index.sh
dbms/tests/queries/0_stateless/00838_unique_index.sh
+3
-3
未找到文件。
dbms/src/Storages/MergeTree/MergeTreeSetSkippingIndex.cpp
浏览文件 @
ca1484ae
...
...
@@ -31,12 +31,12 @@ void MergeTreeSetIndexGranule::serializeBinary(WriteBuffer & ostr) const
{
if
(
empty
())
throw
Exception
(
"Attempt to write empty
unique
index `"
+
index
.
name
+
"`"
,
ErrorCodes
::
LOGICAL_ERROR
);
"Attempt to write empty
set
index `"
+
index
.
name
+
"`"
,
ErrorCodes
::
LOGICAL_ERROR
);
const
auto
&
columns
=
set
->
getSetElements
();
const
auto
&
size_type
=
DataTypePtr
(
std
::
make_shared
<
DataTypeUInt64
>
());
if
(
index
.
max_rows
&&
size
()
>
index
.
max_rows
)
if
(
size
()
>
index
.
max_rows
)
{
size_type
->
serializeBinary
(
0
,
ostr
);
return
;
...
...
@@ -87,7 +87,7 @@ void MergeTreeSetIndexGranule::update(const Block & new_block, size_t * pos, UIn
size_t
rows_read
=
std
::
min
(
limit
,
new_block
.
rows
()
-
*
pos
);
if
(
index
.
max_rows
&&
size
()
>
index
.
max_rows
)
if
(
size
()
>
index
.
max_rows
)
{
*
pos
+=
rows_read
;
return
;
...
...
@@ -112,7 +112,7 @@ void MergeTreeSetIndexGranule::update(const Block & new_block, size_t * pos, UIn
Block
MergeTreeSetIndexGranule
::
getElementsBlock
()
const
{
if
(
index
.
max_rows
&&
size
()
>
index
.
max_rows
)
if
(
size
()
>
index
.
max_rows
)
return
index
.
header
;
return
index
.
header
.
cloneWithColumns
(
set
->
getSetElements
());
}
...
...
@@ -169,12 +169,12 @@ bool SetIndexCondition::mayBeTrueOnGranule(MergeTreeIndexGranulePtr idx_granule)
auto
granule
=
std
::
dynamic_pointer_cast
<
MergeTreeSetIndexGranule
>
(
idx_granule
);
if
(
!
granule
)
throw
Exception
(
"
Unique
index condition got a granule with the wrong type."
,
ErrorCodes
::
LOGICAL_ERROR
);
"
Set
index condition got a granule with the wrong type."
,
ErrorCodes
::
LOGICAL_ERROR
);
if
(
useless
)
return
true
;
if
(
index
.
max_rows
&&
granule
->
size
()
>
index
.
max_rows
)
if
(
granule
->
size
()
>
index
.
max_rows
)
return
true
;
Block
result
=
granule
->
getElementsBlock
();
...
...
@@ -363,14 +363,11 @@ std::unique_ptr<IMergeTreeIndex> setIndexCreator(
throw
Exception
(
"Index must have unique name"
,
ErrorCodes
::
INCORRECT_QUERY
);
size_t
max_rows
=
0
;
if
(
node
->
type
->
arguments
)
{
if
(
node
->
type
->
arguments
->
children
.
size
()
>
1
)
throw
Exception
(
"Unique index cannot have only 0 or 1 argument"
,
ErrorCodes
::
INCORRECT_QUERY
);
else
if
(
node
->
type
->
arguments
->
children
.
size
()
==
1
)
max_rows
=
typeid_cast
<
const
ASTLiteral
&>
(
*
node
->
type
->
arguments
->
children
[
0
]).
value
.
get
<
size_t
>
();
}
if
(
!
node
->
type
->
arguments
||
node
->
type
->
arguments
->
children
.
size
()
!=
1
)
throw
Exception
(
"Set index must have exactly one argument."
,
ErrorCodes
::
INCORRECT_QUERY
);
else
if
(
node
->
type
->
arguments
->
children
.
size
()
==
1
)
max_rows
=
typeid_cast
<
const
ASTLiteral
&>
(
*
node
->
type
->
arguments
->
children
[
0
]).
value
.
get
<
size_t
>
();
ASTPtr
expr_list
=
MergeTreeData
::
extractKeyExpressionList
(
node
->
expr
->
clone
());
...
...
dbms/tests/queries/0_stateless/00838_unique_index.sh
浏览文件 @
ca1484ae
...
...
@@ -16,9 +16,9 @@ CREATE TABLE test.set_idx
s String,
e Enum8('a' = 1, 'b' = 2, 'c' = 3),
dt Date,
INDEX idx_all (i32, i32 + f64, d, s, e, dt) TYPE set GRANULARITY 1,
INDEX idx_all2 (i32, i32 + f64, d, s, e, dt) TYPE set GRANULARITY 2,
INDEX idx_2 (u64 + toYear(dt), substring(s, 2, 4)) TYPE set GRANULARITY 3
INDEX idx_all (i32, i32 + f64, d, s, e, dt) TYPE set
(2)
GRANULARITY 1,
INDEX idx_all2 (i32, i32 + f64, d, s, e, dt) TYPE set
(4)
GRANULARITY 2,
INDEX idx_2 (u64 + toYear(dt), substring(s, 2, 4)) TYPE set
(6)
GRANULARITY 3
) ENGINE = MergeTree()
ORDER BY u64
SETTINGS index_granularity = 2;"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录