Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
09a3b24c
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,发现更多精彩内容 >>
提交
09a3b24c
编写于
3月 11, 2019
作者:
C
chertus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
join kind helpers
上级
49127127
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
15 addition
and
17 deletion
+15
-17
dbms/src/Interpreters/ExpressionActions.cpp
dbms/src/Interpreters/ExpressionActions.cpp
+1
-1
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+1
-1
dbms/src/Interpreters/Join.cpp
dbms/src/Interpreters/Join.cpp
+7
-14
dbms/src/Interpreters/SyntaxAnalyzer.cpp
dbms/src/Interpreters/SyntaxAnalyzer.cpp
+1
-1
dbms/src/Parsers/ASTTablesInSelectQuery.h
dbms/src/Parsers/ASTTablesInSelectQuery.h
+5
-0
未找到文件。
dbms/src/Interpreters/ExpressionActions.cpp
浏览文件 @
09a3b24c
...
...
@@ -1112,7 +1112,7 @@ void ExpressionActions::optimizeArrayJoin()
BlockInputStreamPtr
ExpressionActions
::
createStreamWithNonJoinedDataIfFullOrRightJoin
(
const
Block
&
source_header
,
UInt64
max_block_size
)
const
{
for
(
const
auto
&
action
:
actions
)
if
(
action
.
join
&&
(
action
.
join
->
getKind
()
==
ASTTableJoin
::
Kind
::
Full
||
action
.
join
->
getKind
()
==
ASTTableJoin
::
Kind
::
Right
))
if
(
action
.
join
&&
isRightOrFull
(
action
.
join
->
getKind
()
))
return
action
.
join
->
createStreamWithNonJoinedRows
(
source_header
,
action
.
join_key_names_left
,
action
.
columns_added_by_join
,
max_block_size
);
...
...
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
09a3b24c
...
...
@@ -569,7 +569,7 @@ void InterpreterSelectQuery::executeImpl(Pipeline & pipeline, const BlockInputSt
if
(
expressions
.
hasJoin
())
{
const
ASTTableJoin
&
join
=
static_cast
<
const
ASTTableJoin
&>
(
*
query
.
join
()
->
table_join
);
if
(
join
.
kind
==
ASTTableJoin
::
Kind
::
Full
||
join
.
kind
==
ASTTableJoin
::
Kind
::
Right
)
if
(
isRightOrFull
(
join
.
kind
)
)
pipeline
.
stream_with_non_joined_data
=
expressions
.
before_join
->
createStreamWithNonJoinedDataIfFullOrRightJoin
(
pipeline
.
firstStream
()
->
getHeader
(),
settings
.
max_block_size
);
...
...
dbms/src/Interpreters/Join.cpp
浏览文件 @
09a3b24c
...
...
@@ -220,13 +220,6 @@ struct KeyGetterForType
};
/// Do I need to use the hash table maps_*_full, in which we remember whether the row was joined.
static
bool
getFullness
(
ASTTableJoin
::
Kind
kind
)
{
return
kind
==
ASTTableJoin
::
Kind
::
Right
||
kind
==
ASTTableJoin
::
Kind
::
Full
;
}
void
Join
::
init
(
Type
type_
)
{
type
=
type_
;
...
...
@@ -340,7 +333,7 @@ void Join::setSampleBlock(const Block & block)
}
/// In case of LEFT and FULL joins, if use_nulls, convert joined columns to Nullable.
if
(
use_nulls
&&
(
kind
==
ASTTableJoin
::
Kind
::
Left
||
kind
==
ASTTableJoin
::
Kind
::
Full
))
if
(
use_nulls
&&
isLeftOrFull
(
kind
))
for
(
size_t
i
=
0
;
i
<
num_columns_to_add
;
++
i
)
convertColumnToNullable
(
sample_block_with_columns_to_add
.
getByPosition
(
i
));
}
...
...
@@ -476,7 +469,7 @@ bool Join::insertFromBlock(const Block & block)
blocks
.
push_back
(
block
);
Block
*
stored_block
=
&
blocks
.
back
();
if
(
getFullness
(
kind
))
if
(
isRightOrFull
(
kind
))
{
/** Move the key columns to the beginning of the block.
* This is where NonJoinedBlockInputStream will expect.
...
...
@@ -511,9 +504,9 @@ bool Join::insertFromBlock(const Block & block)
stored_block
->
safeGetByPosition
(
i
).
column
=
stored_block
->
safeGetByPosition
(
i
).
column
->
convertToFullColumnIfConst
();
/// In case of LEFT and FULL joins, if use_nulls, convert joined columns to Nullable.
if
(
use_nulls
&&
(
kind
==
ASTTableJoin
::
Kind
::
Left
||
kind
==
ASTTableJoin
::
Kind
::
Full
))
if
(
use_nulls
&&
isLeftOrFull
(
kind
))
{
for
(
size_t
i
=
getFullness
(
kind
)
?
keys_size
:
0
;
i
<
size
;
++
i
)
for
(
size_t
i
=
isFull
(
kind
)
?
keys_size
:
0
;
i
<
size
;
++
i
)
{
convertColumnToNullable
(
stored_block
->
getByPosition
(
i
));
}
...
...
@@ -721,7 +714,7 @@ void Join::joinBlockImpl(
* Because if they are constants, then in the "not joined" rows, they may have different values
* - default values, which can differ from the values of these constants.
*/
if
(
getFullness
(
kind
))
if
(
isRightOrFull
(
kind
))
{
for
(
size_t
i
=
0
;
i
<
existing_columns
;
++
i
)
{
...
...
@@ -741,7 +734,7 @@ void Join::joinBlockImpl(
* but they will not be used at this stage of joining (and will be in `AdderNonJoined`), and they need to be skipped.
*/
size_t
num_columns_to_skip
=
0
;
if
(
getFullness
(
kind
))
if
(
isRightOrFull
(
kind
))
num_columns_to_skip
=
keys_size
;
/// Add new columns to the block.
...
...
@@ -798,7 +791,7 @@ void Join::joinBlockImpl(
if
(
strictness
==
ASTTableJoin
::
Strictness
::
Any
)
{
if
(
kind
==
ASTTableJoin
::
Kind
::
Inner
||
kind
==
ASTTableJoin
::
Kind
::
Right
)
if
(
isInnerOrRight
(
kind
)
)
{
/// If ANY INNER | RIGHT JOIN - filter all the columns except the new ones.
for
(
size_t
i
=
0
;
i
<
existing_columns
;
++
i
)
...
...
dbms/src/Interpreters/SyntaxAnalyzer.cpp
浏览文件 @
09a3b24c
...
...
@@ -573,7 +573,7 @@ void collectJoinedColumns(AnalyzedJoin & analyzed_join, const ASTSelectQuery & s
else
if
(
table_join
.
on_expression
)
collectJoinedColumnsFromJoinOnExpr
(
analyzed_join
,
table_join
);
bool
make_nullable
=
join_use_nulls
&&
(
table_join
.
kind
==
ASTTableJoin
::
Kind
::
Left
||
table_join
.
kind
==
ASTTableJoin
::
Kind
::
Full
);
bool
make_nullable
=
join_use_nulls
&&
isLeftOrFull
(
table_join
.
kind
);
analyzed_join
.
calculateAvailableJoinedColumns
(
make_nullable
);
}
...
...
dbms/src/Parsers/ASTTablesInSelectQuery.h
浏览文件 @
09a3b24c
...
...
@@ -106,6 +106,11 @@ struct ASTTableJoin : public IAST
void
formatImpl
(
const
FormatSettings
&
settings
,
FormatState
&
state
,
FormatStateStacked
frame
)
const
override
;
};
inline
bool
isFull
(
ASTTableJoin
::
Kind
kind
)
{
return
kind
==
ASTTableJoin
::
Kind
::
Full
;
}
inline
bool
isRightOrFull
(
ASTTableJoin
::
Kind
kind
)
{
return
kind
==
ASTTableJoin
::
Kind
::
Right
||
kind
==
ASTTableJoin
::
Kind
::
Full
;
}
inline
bool
isLeftOrFull
(
ASTTableJoin
::
Kind
kind
)
{
return
kind
==
ASTTableJoin
::
Kind
::
Left
||
kind
==
ASTTableJoin
::
Kind
::
Full
;
}
inline
bool
isInnerOrRight
(
ASTTableJoin
::
Kind
kind
)
{
return
kind
==
ASTTableJoin
::
Kind
::
Inner
||
kind
==
ASTTableJoin
::
Kind
::
Right
;
}
/// Specification of ARRAY JOIN.
struct
ASTArrayJoin
:
public
IAST
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录