Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
02337242
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,发现更多精彩内容 >>
提交
02337242
编写于
10月 15, 2018
作者:
A
Alexey Zatelepin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ALTER MODIFY ORDER BY syntax [#CLICKHOUSE-3859]
上级
c4bf38ef
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
1 deletion
+45
-1
dbms/src/Parsers/ASTAlterQuery.cpp
dbms/src/Parsers/ASTAlterQuery.cpp
+12
-0
dbms/src/Parsers/ASTAlterQuery.h
dbms/src/Parsers/ASTAlterQuery.h
+5
-0
dbms/src/Parsers/ParserAlterQuery.cpp
dbms/src/Parsers/ParserAlterQuery.cpp
+16
-0
dbms/src/Storages/AlterCommands.cpp
dbms/src/Storages/AlterCommands.cpp
+8
-1
dbms/src/Storages/AlterCommands.h
dbms/src/Storages/AlterCommands.h
+4
-0
未找到文件。
dbms/src/Parsers/ASTAlterQuery.cpp
浏览文件 @
02337242
...
...
@@ -30,6 +30,11 @@ ASTPtr ASTAlterCommand::clone() const
res
->
primary_key
=
primary_key
->
clone
();
res
->
children
.
push_back
(
res
->
primary_key
);
}
if
(
sorting_key
)
{
res
->
sorting_key
=
sorting_key
->
clone
();
res
->
children
.
push_back
(
res
->
sorting_key
);
}
if
(
partition
)
{
res
->
partition
=
partition
->
clone
();
...
...
@@ -84,6 +89,13 @@ void ASTAlterCommand::formatImpl(
primary_key
->
formatImpl
(
settings
,
state
,
frame
);
settings
.
ostr
<<
")"
;
}
else
if
(
type
==
ASTAlterCommand
::
MODIFY_ORDER_BY
)
{
settings
.
ostr
<<
(
settings
.
hilite
?
hilite_keyword
:
""
)
<<
indent_str
<<
"MODIFY ORDER BY "
<<
(
settings
.
hilite
?
hilite_none
:
""
);
settings
.
ostr
<<
"("
;
sorting_key
->
formatImpl
(
settings
,
state
,
frame
);
settings
.
ostr
<<
")"
;
}
else
if
(
type
==
ASTAlterCommand
::
DROP_PARTITION
)
{
settings
.
ostr
<<
(
settings
.
hilite
?
hilite_keyword
:
""
)
<<
indent_str
<<
(
detach
?
"DETACH"
:
"DROP"
)
<<
" PARTITION "
...
...
dbms/src/Parsers/ASTAlterQuery.h
浏览文件 @
02337242
...
...
@@ -25,6 +25,7 @@ public:
DROP_COLUMN
,
MODIFY_COLUMN
,
MODIFY_PRIMARY_KEY
,
MODIFY_ORDER_BY
,
DROP_PARTITION
,
ATTACH_PARTITION
,
...
...
@@ -55,6 +56,10 @@ public:
*/
ASTPtr
primary_key
;
/** For MODIFY ORDER BY
*/
ASTPtr
sorting_key
;
/** Used in DROP PARTITION and ATTACH PARTITION FROM queries.
* The value or ID of the partition is stored here.
*/
...
...
dbms/src/Parsers/ParserAlterQuery.cpp
浏览文件 @
02337242
...
...
@@ -24,6 +24,7 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
ParserKeyword
s_clear_column
(
"CLEAR COLUMN"
);
ParserKeyword
s_modify_column
(
"MODIFY COLUMN"
);
ParserKeyword
s_modify_primary_key
(
"MODIFY PRIMARY KEY"
);
ParserKeyword
s_modify_order_by
(
"MODIFY ORDER BY"
);
ParserKeyword
s_attach_partition
(
"ATTACH PARTITION"
);
ParserKeyword
s_detach_partition
(
"DETACH PARTITION"
);
...
...
@@ -200,6 +201,21 @@ bool ParserAlterCommand::parseImpl(Pos & pos, ASTPtr & node, Expected & expected
command
->
type
=
ASTAlterCommand
::
MODIFY_PRIMARY_KEY
;
}
else
if
(
s_modify_order_by
.
ignore
(
pos
,
expected
))
{
if
(
pos
->
type
!=
TokenType
::
OpeningRoundBracket
)
return
false
;
++
pos
;
if
(
!
ParserNotEmptyExpressionList
(
false
).
parse
(
pos
,
command
->
sorting_key
,
expected
))
return
false
;
if
(
pos
->
type
!=
TokenType
::
ClosingRoundBracket
)
return
false
;
++
pos
;
command
->
type
=
ASTAlterCommand
::
MODIFY_ORDER_BY
;
}
else
if
(
s_delete_where
.
ignore
(
pos
,
expected
))
{
if
(
!
parser_exp_elem
.
parse
(
pos
,
command
->
predicate
,
expected
))
...
...
dbms/src/Storages/AlterCommands.cpp
浏览文件 @
02337242
...
...
@@ -90,6 +90,13 @@ std::optional<AlterCommand> AlterCommand::parse(const ASTAlterCommand * command_
command
.
primary_key
=
command_ast
->
primary_key
;
return
command
;
}
else
if
(
command_ast
->
type
==
ASTAlterCommand
::
MODIFY_ORDER_BY
)
{
AlterCommand
command
;
command
.
type
=
AlterCommand
::
MODIFY_ORDER_BY
;
command
.
sorting_key
=
command_ast
->
sorting_key
;
return
command
;
}
else
return
{};
}
...
...
@@ -232,7 +239,7 @@ void AlterCommand::apply(ColumnsDescription & columns_description) const
/// both old and new columns have default expression, update it
columns_description
.
defaults
[
column_name
].
expression
=
default_expression
;
}
else
if
(
type
==
MODIFY_PRIMARY_KEY
)
else
if
(
type
==
MODIFY_PRIMARY_KEY
||
type
==
MODIFY_ORDER_BY
)
{
/// This have no relation to changing the list of columns.
/// TODO Check that all columns exist, that only columns with constant defaults are added.
...
...
dbms/src/Storages/AlterCommands.h
浏览文件 @
02337242
...
...
@@ -21,6 +21,7 @@ struct AlterCommand
DROP_COLUMN
,
MODIFY_COLUMN
,
MODIFY_PRIMARY_KEY
,
MODIFY_ORDER_BY
,
};
Type
type
;
...
...
@@ -42,6 +43,9 @@ struct AlterCommand
/// For MODIFY_PRIMARY_KEY
ASTPtr
primary_key
;
/// For MODIFY_ORDER_BY
ASTPtr
sorting_key
;
AlterCommand
()
=
default
;
AlterCommand
(
const
Type
type
,
const
String
&
column_name
,
const
DataTypePtr
&
data_type
,
const
ColumnDefaultKind
default_kind
,
const
ASTPtr
&
default_expression
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录