Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
82985ff5
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,发现更多精彩内容 >>
提交
82985ff5
编写于
4月 20, 2020
作者:
V
Vladimir Chebotarev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allowed to alter column in non-modifying data mode when the same type is specified.
上级
61d33a8d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
139 addition
and
7 deletion
+139
-7
src/Storages/AlterCommands.cpp
src/Storages/AlterCommands.cpp
+15
-4
src/Storages/AlterCommands.h
src/Storages/AlterCommands.h
+2
-2
src/Storages/MergeTree/MergeTreeData.cpp
src/Storages/MergeTree/MergeTreeData.cpp
+1
-1
tests/integration/test_alter_codec/__init__.py
tests/integration/test_alter_codec/__init__.py
+0
-0
tests/integration/test_alter_codec/configs/config.d/cluster.xml
...integration/test_alter_codec/configs/config.d/cluster.xml
+16
-0
tests/integration/test_alter_codec/configs/logs_config.xml
tests/integration/test_alter_codec/configs/logs_config.xml
+17
-0
tests/integration/test_alter_codec/test.py
tests/integration/test_alter_codec/test.py
+88
-0
未找到文件。
src/Storages/AlterCommands.cpp
浏览文件 @
82985ff5
...
...
@@ -472,11 +472,22 @@ void AlterCommand::apply(StorageInMemoryMetadata & metadata) const
throw
Exception
(
"Wrong parameter type in ALTER query"
,
ErrorCodes
::
LOGICAL_ERROR
);
}
bool
AlterCommand
::
isModifyingData
()
const
bool
AlterCommand
::
isModifyingData
(
const
StorageInMemoryMetadata
&
metadata
)
const
{
/// Possible change data representation on disk
if
(
type
==
MODIFY_COLUMN
)
return
data_type
!=
nullptr
;
{
if
(
data_type
==
nullptr
)
return
false
;
for
(
const
auto
&
column
:
metadata
.
columns
.
getAllPhysical
())
{
if
(
column
.
name
==
column_name
)
return
column
.
type
->
getName
()
!=
data_type
->
getName
();
}
return
true
;
}
return
type
==
ADD_COLUMN
/// We need to change columns.txt in each part for MergeTree
||
type
==
DROP_COLUMN
/// We need to change columns.txt in each part for MergeTree
...
...
@@ -888,11 +899,11 @@ void AlterCommands::validate(const StorageInMemoryMetadata & metadata, const Con
validateColumnsDefaultsAndGetSampleBlock
(
default_expr_list
,
all_columns
.
getAll
(),
context
);
}
bool
AlterCommands
::
isModifyingData
()
const
bool
AlterCommands
::
isModifyingData
(
const
StorageInMemoryMetadata
&
metadata
)
const
{
for
(
const
auto
&
param
:
*
this
)
{
if
(
param
.
isModifyingData
())
if
(
param
.
isModifyingData
(
metadata
))
return
true
;
}
...
...
src/Storages/AlterCommands.h
浏览文件 @
82985ff5
...
...
@@ -108,7 +108,7 @@ struct AlterCommand
/// * column files (data and marks)
/// * each part meta (columns.txt)
/// in each part on disk (it's not lightweight alter).
bool
isModifyingData
()
const
;
bool
isModifyingData
(
const
StorageInMemoryMetadata
&
metadata
)
const
;
bool
isRequireMutationStage
(
const
StorageInMemoryMetadata
&
metadata
)
const
;
...
...
@@ -151,7 +151,7 @@ public:
void
apply
(
StorageInMemoryMetadata
&
metadata
)
const
;
/// At least one command modify data on disk.
bool
isModifyingData
()
const
;
bool
isModifyingData
(
const
StorageInMemoryMetadata
&
metadata
)
const
;
/// At least one command modify settings.
bool
isSettingsAlter
()
const
;
...
...
src/Storages/MergeTree/MergeTreeData.cpp
浏览文件 @
82985ff5
...
...
@@ -1484,7 +1484,7 @@ void MergeTreeData::checkAlterIsPossible(const AlterCommands & commands, const S
ErrorCodes
::
ILLEGAL_COLUMN
);
}
}
else
if
(
command
.
isModifyingData
())
else
if
(
command
.
isModifyingData
(
getInMemoryMetadata
()
))
{
if
(
columns_alter_type_forbidden
.
count
(
command
.
column_name
))
throw
Exception
(
"Trying to ALTER key column "
+
command
.
column_name
,
ErrorCodes
::
ILLEGAL_COLUMN
);
...
...
tests/integration/test_alter_codec/__init__.py
0 → 100644
浏览文件 @
82985ff5
tests/integration/test_alter_codec/configs/config.d/cluster.xml
0 → 100644
浏览文件 @
82985ff5
<yandex>
<remote_servers>
<test_cluster>
<shard>
<replica>
<host>
node1
</host>
<port>
9000
</port>
</replica>
<replica>
<host>
node2
</host>
<port>
9000
</port>
</replica>
</shard>
</test_cluster>
</remote_servers>
</yandex>
\ No newline at end of file
tests/integration/test_alter_codec/configs/logs_config.xml
0 → 100644
浏览文件 @
82985ff5
<yandex>
<shutdown_wait_unfinished>
3
</shutdown_wait_unfinished>
<logger>
<level>
trace
</level>
<log>
/var/log/clickhouse-server/log.log
</log>
<errorlog>
/var/log/clickhouse-server/log.err.log
</errorlog>
<size>
1000M
</size>
<count>
10
</count>
<stderr>
/var/log/clickhouse-server/stderr.log
</stderr>
<stdout>
/var/log/clickhouse-server/stdout.log
</stdout>
</logger>
<part_log>
<database>
system
</database>
<table>
part_log
</table>
<flush_interval_milliseconds>
500
</flush_interval_milliseconds>
</part_log>
</yandex>
tests/integration/test_alter_codec/test.py
0 → 100644
浏览文件 @
82985ff5
import
pytest
from
helpers.client
import
QueryRuntimeException
from
helpers.cluster
import
ClickHouseCluster
cluster
=
ClickHouseCluster
(
__file__
)
node1
=
cluster
.
add_instance
(
'node1'
,
config_dir
=
'configs'
,
main_configs
=
[
'configs/logs_config.xml'
],
with_zookeeper
=
True
,
macros
=
{
"shard"
:
0
,
"replica"
:
1
}
)
node2
=
cluster
.
add_instance
(
'node2'
,
config_dir
=
'configs'
,
main_configs
=
[
'configs/logs_config.xml'
],
with_zookeeper
=
True
,
macros
=
{
"shard"
:
0
,
"replica"
:
2
}
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
started_cluster
():
try
:
cluster
.
start
()
yield
cluster
finally
:
cluster
.
shutdown
()
def
test_alter_codec_pk
(
started_cluster
):
try
:
name
=
"test_alter_codec_pk"
node1
.
query
(
"""
CREATE TABLE {name} (id UInt64) Engine=MergeTree() ORDER BY id
"""
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 CODEC(NONE)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt32 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 DEFAULT 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 ALIAS 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 MATERIALIZED 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id Int64"
.
format
(
name
=
name
))
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {name}"
.
format
(
name
=
name
))
def
test_alter_codec_index
(
started_cluster
):
try
:
name
=
"test_alter_codec_index"
node1
.
query
(
"""
CREATE TABLE {name} (`id` UInt64, INDEX id_index id TYPE minmax GRANULARITY 1) Engine=MergeTree() ORDER BY tuple()
"""
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 CODEC(NONE)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt32 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 DEFAULT 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 ALIAS 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64 MATERIALIZED 3 CODEC(Delta, LZ4)"
.
format
(
name
=
name
))
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id UInt64"
.
format
(
name
=
name
))
with
pytest
.
raises
(
QueryRuntimeException
):
node1
.
query
(
"ALTER TABLE {name} MODIFY COLUMN id Int64"
.
format
(
name
=
name
))
finally
:
node1
.
query
(
"DROP TABLE IF EXISTS {name}"
.
format
(
name
=
name
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录