Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
66dd568e
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,发现更多精彩内容 >>
提交
66dd568e
编写于
1月 12, 2018
作者:
Z
zhang2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ISSUES-957 update condition & test
上级
6f28e0a6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
18 addition
and
15 deletion
+18
-15
dbms/src/Interpreters/InterpreterCreateQuery.cpp
dbms/src/Interpreters/InterpreterCreateQuery.cpp
+1
-1
dbms/src/Interpreters/InterpreterFactory.cpp
dbms/src/Interpreters/InterpreterFactory.cpp
+2
-1
dbms/src/Interpreters/InterpreterInsertQuery.cpp
dbms/src/Interpreters/InterpreterInsertQuery.cpp
+4
-3
dbms/src/Interpreters/InterpreterInsertQuery.h
dbms/src/Interpreters/InterpreterInsertQuery.h
+2
-1
dbms/src/Storages/StorageBuffer.cpp
dbms/src/Storages/StorageBuffer.cpp
+5
-5
dbms/src/Storages/StorageBuffer.h
dbms/src/Storages/StorageBuffer.h
+2
-1
dbms/tests/queries/0_stateless/00553_buff_exists_materlized_column.sql
...eries/0_stateless/00553_buff_exists_materlized_column.sql
+2
-3
未找到文件。
dbms/src/Interpreters/InterpreterCreateQuery.cpp
浏览文件 @
66dd568e
...
...
@@ -572,7 +572,7 @@ BlockIO InterpreterCreateQuery::createTable(ASTCreateQuery & create)
out
=
std
::
make_shared
<
AddingDefaultBlockOutputStream
>
(
out
,
columns
.
columns
,
columns
.
column_defaults
,
context
,
strict_insert_defaults
);
if
(
context
.
getSettingsRef
().
insert_allow_materialized_columns
)
if
(
!
context
.
getSettingsRef
().
insert_allow_materialized_columns
)
out
=
std
::
make_shared
<
ProhibitColumnsBlockOutputStream
>
(
out
,
columns
.
materialized_columns
);
BlockIO
io
;
...
...
dbms/src/Interpreters/InterpreterFactory.cpp
浏览文件 @
66dd568e
...
...
@@ -61,7 +61,8 @@ std::unique_ptr<IInterpreter> InterpreterFactory::get(ASTPtr & query, Context &
else
if
(
typeid_cast
<
ASTInsertQuery
*>
(
query
.
get
()))
{
/// readonly is checked inside InterpreterInsertQuery
return
std
::
make_unique
<
InterpreterInsertQuery
>
(
query
,
context
);
bool
allow_materialized
=
static_cast
<
bool
>
(
context
.
getSettingsRef
().
insert_allow_materialized_columns
);
return
std
::
make_unique
<
InterpreterInsertQuery
>
(
query
,
context
,
allow_materialized
);
}
else
if
(
typeid_cast
<
ASTCreateQuery
*>
(
query
.
get
()))
{
...
...
dbms/src/Interpreters/InterpreterInsertQuery.cpp
浏览文件 @
66dd568e
...
...
@@ -37,8 +37,9 @@ namespace ErrorCodes
}
InterpreterInsertQuery
::
InterpreterInsertQuery
(
const
ASTPtr
&
query_ptr_
,
const
Context
&
context_
)
:
query_ptr
(
query_ptr_
),
context
(
context_
)
InterpreterInsertQuery
::
InterpreterInsertQuery
(
const
ASTPtr
&
query_ptr_
,
const
Context
&
context_
,
bool
allow_materialized_
)
:
query_ptr
(
query_ptr_
),
context
(
context_
),
allow_materialized
(
allow_materialized_
)
{
ProfileEvents
::
increment
(
ProfileEvents
::
InsertQuery
);
}
...
...
@@ -118,7 +119,7 @@ BlockIO InterpreterInsertQuery::execute()
out
=
std
::
make_shared
<
AddingDefaultBlockOutputStream
>
(
out
,
required_columns
,
table
->
column_defaults
,
context
,
static_cast
<
bool
>
(
context
.
getSettingsRef
().
strict_insert_defaults
));
if
(
context
.
getSettingsRef
().
insert_allow_materialized_columns
)
if
(
!
allow_materialized
)
out
=
std
::
make_shared
<
ProhibitColumnsBlockOutputStream
>
(
out
,
table
->
materialized_columns
);
out
=
std
::
make_shared
<
SquashingBlockOutputStream
>
(
...
...
dbms/src/Interpreters/InterpreterInsertQuery.h
浏览文件 @
66dd568e
...
...
@@ -15,7 +15,7 @@ namespace DB
class
InterpreterInsertQuery
:
public
IInterpreter
{
public:
InterpreterInsertQuery
(
const
ASTPtr
&
query_ptr_
,
const
Context
&
context_
);
InterpreterInsertQuery
(
const
ASTPtr
&
query_ptr_
,
const
Context
&
context_
,
bool
allow_materialized_
=
false
);
/** Prepare a request for execution. Return block streams
* - the stream into which you can write data to execute the query, if INSERT;
...
...
@@ -37,6 +37,7 @@ private:
ASTPtr
query_ptr
;
const
Context
&
context
;
bool
allow_materialized
;
};
...
...
dbms/src/Storages/StorageBuffer.cpp
浏览文件 @
66dd568e
...
...
@@ -55,14 +55,14 @@ StorageBuffer::StorageBuffer(const std::string & name_, const NamesAndTypesList
const
ColumnDefaults
&
column_defaults_
,
Context
&
context_
,
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
)
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
)
:
IStorage
{
materialized_columns_
,
alias_columns_
,
column_defaults_
},
name
(
name_
),
columns
(
columns_
),
context
(
context_
),
num_shards
(
num_shards_
),
buffers
(
num_shards_
),
min_thresholds
(
min_thresholds_
),
max_thresholds
(
max_thresholds_
),
destination_database
(
destination_database_
),
destination_table
(
destination_table_
),
no_destination
(
destination_database
.
empty
()
&&
destination_table
.
empty
()),
log
(
&
Logger
::
get
(
"StorageBuffer ("
+
name
+
")"
))
allow_materialized
(
allow_materialized_
),
log
(
&
Logger
::
get
(
"StorageBuffer ("
+
name
+
")"
))
{
}
...
...
@@ -527,7 +527,6 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl
/** We will insert columns that are the intersection set of columns of the buffer table and the subordinate table.
* This will support some of the cases (but not all) when the table structure does not match.
*/
bool
allow_materialized
=
static_cast
<
bool
>
(
context
.
getSettingsRef
().
insert_allow_materialized_columns
);
Block
structure_of_destination_table
=
allow_materialized
?
table
->
getSampleBlock
()
:
table
->
getSampleBlockNonMaterialized
();
Names
columns_intersection
;
columns_intersection
.
reserve
(
block
.
columns
());
...
...
@@ -565,7 +564,7 @@ void StorageBuffer::writeBlockToDestination(const Block & block, StoragePtr tabl
for
(
const
String
&
column
:
columns_intersection
)
list_of_columns
->
children
.
push_back
(
std
::
make_shared
<
ASTIdentifier
>
(
StringRange
(),
column
,
ASTIdentifier
::
Column
));
InterpreterInsertQuery
interpreter
{
insert
,
context
};
InterpreterInsertQuery
interpreter
{
insert
,
context
,
allow_materialized
};
auto
block_io
=
interpreter
.
execute
();
block_io
.
out
->
writePrefix
();
...
...
@@ -651,7 +650,8 @@ void registerStorageBuffer(StorageFactory & factory)
num_buckets
,
StorageBuffer
::
Thresholds
{
min_time
,
min_rows
,
min_bytes
},
StorageBuffer
::
Thresholds
{
max_time
,
max_rows
,
max_bytes
},
destination_database
,
destination_table
);
destination_database
,
destination_table
,
static_cast
<
bool
>
(
args
.
local_context
.
getSettingsRef
().
insert_allow_materialized_columns
));
});
}
...
...
dbms/src/Storages/StorageBuffer.h
浏览文件 @
66dd568e
...
...
@@ -103,6 +103,7 @@ private:
const
String
destination_database
;
const
String
destination_table
;
bool
no_destination
;
/// If set, do not write data from the buffer, but simply empty the buffer.
bool
allow_materialized
;
Poco
::
Logger
*
log
;
...
...
@@ -131,7 +132,7 @@ protected:
const
ColumnDefaults
&
column_defaults_
,
Context
&
context_
,
size_t
num_shards_
,
const
Thresholds
&
min_thresholds_
,
const
Thresholds
&
max_thresholds_
,
const
String
&
destination_database_
,
const
String
&
destination_table_
);
const
String
&
destination_database_
,
const
String
&
destination_table_
,
bool
allow_materialized_
);
};
}
dbms/tests/queries/0_stateless/00553_buff_exists_materlized_column.sql
浏览文件 @
66dd568e
DROP
TABLE
IF
EXISTS
test
.
nums
;
DROP
TABLE
IF
EXISTS
test
.
nums_buf
;
SET
insert_allow_materialized_columns
=
1
;
CREATE
TABLE
test
.
nums
(
n
UInt64
,
m
UInt64
MATERIALIZED
n
+
1
)
ENGINE
=
Log
;
CREATE
TABLE
test
.
nums_buf
AS
test
.
nums
ENGINE
=
Buffer
(
test
,
nums
,
1
,
10
,
100
,
1
,
3
,
10000000
,
100000000
);
...
...
@@ -11,10 +13,7 @@ INSERT INTO test.nums_buf (n) VALUES (4);
INSERT
INTO
test
.
nums_buf
(
n
)
VALUES
(
5
);
SELECT
n
,
m
FROM
test
.
nums
ORDER
BY
n
;
SELECT
n
,
m
FROM
test
.
nums_buf
ORDER
BY
n
;
DROP
TABLE
IF
EXISTS
test
.
nums
;
DROP
TABLE
IF
EXISTS
test
.
nums_buf
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录