Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
8bb35ac9
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,发现更多精彩内容 >>
提交
8bb35ac9
编写于
1月 15, 2019
作者:
C
chertus
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor changes
上级
6433d5ef
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
23 addition
and
28 deletion
+23
-28
dbms/src/Interpreters/AddDefaultDatabaseVisitor.h
dbms/src/Interpreters/AddDefaultDatabaseVisitor.h
+0
-5
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
+3
-11
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
+1
-1
dbms/src/Interpreters/ExpressionAnalyzer.cpp
dbms/src/Interpreters/ExpressionAnalyzer.cpp
+1
-1
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
+2
-2
dbms/src/Interpreters/InterpreterSelectQuery.cpp
dbms/src/Interpreters/InterpreterSelectQuery.cpp
+14
-6
dbms/src/Storages/StorageMaterializedView.cpp
dbms/src/Storages/StorageMaterializedView.cpp
+2
-2
未找到文件。
dbms/src/Interpreters/AddDefaultDatabaseVisitor.h
浏览文件 @
8bb35ac9
...
...
@@ -90,12 +90,7 @@ private:
void
visit
(
ASTTableExpression
&
table_expression
,
ASTPtr
&
)
const
{
if
(
table_expression
.
database_and_table_name
)
{
tryVisit
<
ASTIdentifier
>
(
table_expression
.
database_and_table_name
);
if
(
table_expression
.
database_and_table_name
->
children
.
size
()
!=
2
)
throw
Exception
(
"Logical error: more than two components in table expression"
,
ErrorCodes
::
LOGICAL_ERROR
);
}
else
if
(
table_expression
.
subquery
)
tryVisit
<
ASTSubquery
>
(
table_expression
.
subquery
);
}
...
...
dbms/src/Interpreters/DatabaseAndTableWithAlias.cpp
浏览文件 @
8bb35ac9
...
...
@@ -209,21 +209,13 @@ std::optional<DatabaseAndTableWithAlias> getDatabaseAndTable(const ASTSelectQuer
return
DatabaseAndTableWithAlias
(
database_and_table_name
);
}
ASTPtr
getTableFunctionOrSubquery
(
const
ASTSelectQuery
&
select
,
size_t
table_number
)
ASTPtr
extractTableExpression
(
const
ASTSelectQuery
&
select
,
size_t
table_number
)
{
const
ASTTableExpression
*
table_expression
=
getTableExpression
(
select
,
table_number
);
if
(
table_expression
)
if
(
const
ASTTableExpression
*
table_expression
=
getTableExpression
(
select
,
table_number
))
{
#if 1 /// TODO: It hides some logical error in InterpreterSelectQuery & distributed tables
if
(
table_expression
->
database_and_table_name
)
{
if
(
table_expression
->
database_and_table_name
->
children
.
empty
())
return
table_expression
->
database_and_table_name
;
return
table_expression
->
database_and_table_name
;
if
(
table_expression
->
database_and_table_name
->
children
.
size
()
==
2
)
return
table_expression
->
database_and_table_name
->
children
[
1
];
}
#endif
if
(
table_expression
->
table_function
)
return
table_expression
->
table_function
;
...
...
dbms/src/Interpreters/DatabaseAndTableWithAlias.h
浏览文件 @
8bb35ac9
...
...
@@ -44,6 +44,6 @@ std::vector<DatabaseAndTableWithAlias> getDatabaseAndTables(const ASTSelectQuery
std
::
optional
<
DatabaseAndTableWithAlias
>
getDatabaseAndTable
(
const
ASTSelectQuery
&
select
,
size_t
table_number
);
std
::
vector
<
const
ASTTableExpression
*>
getSelectTablesExpression
(
const
ASTSelectQuery
&
select_query
);
ASTPtr
getTableFunctionOrSubquery
(
const
ASTSelectQuery
&
select
,
size_t
table_number
);
ASTPtr
extractTableExpression
(
const
ASTSelectQuery
&
select
,
size_t
table_number
);
}
dbms/src/Interpreters/ExpressionAnalyzer.cpp
浏览文件 @
8bb35ac9
...
...
@@ -310,7 +310,7 @@ void ExpressionAnalyzer::makeSetsForIndexImpl(const ASTPtr & node, const Block &
if
(
!
prepared_sets
.
count
(
arg
->
range
))
/// Not already prepared.
{
if
(
typeid_cast
<
ASTSubquery
*>
(
arg
.
get
())
||
typeid_cast
<
ASTIdentifier
*>
(
arg
.
get
()
))
if
(
typeid_cast
<
ASTSubquery
*>
(
arg
.
get
())
||
isIdentifier
(
arg
))
{
if
(
settings
.
use_index_for_in_with_subqueries
)
tryMakeSetForIndexFromSubquery
(
arg
);
...
...
dbms/src/Interpreters/GlobalSubqueriesVisitor.h
浏览文件 @
8bb35ac9
...
...
@@ -55,7 +55,7 @@ public:
ASTPtr
table_name
;
ASTPtr
subquery_or_table_name
;
if
(
typeid_cast
<
const
ASTIdentifier
*>
(
subquery_or_table_name_or_table_expression
.
get
()
))
if
(
isIdentifier
(
subquery_or_table_name_or_table_expression
))
{
table_name
=
subquery_or_table_name_or_table_expression
;
subquery_or_table_name
=
table_name
;
...
...
@@ -86,7 +86,7 @@ public:
if
(
table_name
)
{
/// If this is already an external table, you do not need to add anything. Just remember its presence.
if
(
external_tables
.
end
()
!=
external_tables
.
find
(
static_cast
<
const
ASTIdentifier
&>
(
*
table_name
).
name
))
if
(
external_tables
.
end
()
!=
external_tables
.
find
(
*
getIdentifierName
(
table_name
)
))
return
;
}
...
...
dbms/src/Interpreters/InterpreterSelectQuery.cpp
浏览文件 @
8bb35ac9
...
...
@@ -147,14 +147,22 @@ InterpreterSelectQuery::InterpreterSelectQuery(
max_streams
=
settings
.
max_threads
;
ASTPtr
table_expression
=
getTableFunctionOrSubquery
(
query
,
0
);
ASTPtr
table_expression
=
extractTableExpression
(
query
,
0
);
bool
is_table_func
=
false
;
bool
is_subquery
=
false
;
if
(
table_expression
)
{
is_table_func
=
typeid_cast
<
const
ASTFunction
*>
(
table_expression
.
get
());
is_subquery
=
typeid_cast
<
const
ASTSelectWithUnionQuery
*>
(
table_expression
.
get
());
}
if
(
input
)
{
/// Read from prepared input.
source_header
=
input
->
getHeader
();
}
else
if
(
table_expression
&&
typeid_cast
<
const
ASTSelectWithUnionQuery
*>
(
table_expression
.
get
())
)
else
if
(
is_subquery
)
{
/// Read from subquery.
interpreter_subquery
=
std
::
make_unique
<
InterpreterSelectWithUnionQuery
>
(
...
...
@@ -164,7 +172,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
}
else
if
(
!
storage
)
{
if
(
table_expression
&&
typeid_cast
<
const
ASTFunction
*>
(
table_expression
.
get
())
)
if
(
is_table_func
)
{
/// Read from table function.
storage
=
context
.
getQueryContext
().
executeTableFunction
(
table_expression
);
...
...
@@ -208,7 +216,7 @@ InterpreterSelectQuery::InterpreterSelectQuery(
if
(
query_analyzer
->
isRewriteSubqueriesPredicate
())
{
/// remake interpreter_subquery when PredicateOptimizer is rewrite subqueries and main table is subquery
if
(
table_expression
&&
typeid_cast
<
ASTSelectWithUnionQuery
*>
(
table_expression
.
get
())
)
if
(
is_subquery
)
interpreter_subquery
=
std
::
make_unique
<
InterpreterSelectWithUnionQuery
>
(
table_expression
,
getSubqueryContext
(
context
),
required_columns
,
QueryProcessingStage
::
Complete
,
subquery_depth
+
1
,
only_analyze
);
...
...
@@ -921,7 +929,7 @@ void InterpreterSelectQuery::executeFetchColumns(
/// If we need less number of columns that subquery have - update the interpreter.
if
(
required_columns
.
size
()
<
source_header
.
columns
())
{
ASTPtr
subquery
=
getTableFunctionOrSubquery
(
query
,
0
);
ASTPtr
subquery
=
extractTableExpression
(
query
,
0
);
if
(
!
subquery
)
throw
Exception
(
"Subquery expected"
,
ErrorCodes
::
LOGICAL_ERROR
);
...
...
@@ -1396,7 +1404,7 @@ bool hasWithTotalsInAnySubqueryInFromClause(const ASTSelectQuery & query)
* In other cases, totals will be computed on the initiating server of the query, and it is not necessary to read the data to the end.
*/
if
(
auto
query_table
=
getTableFunctionOrSubquery
(
query
,
0
))
if
(
auto
query_table
=
extractTableExpression
(
query
,
0
))
{
if
(
auto
ast_union
=
typeid_cast
<
const
ASTSelectWithUnionQuery
*>
(
query_table
.
get
()))
{
...
...
dbms/src/Storages/StorageMaterializedView.cpp
浏览文件 @
8bb35ac9
...
...
@@ -30,7 +30,7 @@ namespace ErrorCodes
static
void
extractDependentTable
(
ASTSelectQuery
&
query
,
String
&
select_database_name
,
String
&
select_table_name
)
{
auto
db_and_table
=
getDatabaseAndTable
(
query
,
0
);
ASTPtr
subquery
=
getTableFunctionOrSubquery
(
query
,
0
);
ASTPtr
subquery
=
extractTableExpression
(
query
,
0
);
if
(
!
db_and_table
&&
!
subquery
)
return
;
...
...
@@ -69,7 +69,7 @@ static void checkAllowedQueries(const ASTSelectQuery & query)
if
(
query
.
prewhere_expression
||
query
.
final
()
||
query
.
sample_size
())
throw
Exception
(
"MATERIALIZED VIEW cannot have PREWHERE, SAMPLE or FINAL."
,
DB
::
ErrorCodes
::
QUERY_IS_NOT_SUPPORTED_IN_MATERIALIZED_VIEW
);
ASTPtr
subquery
=
getTableFunctionOrSubquery
(
query
,
0
);
ASTPtr
subquery
=
extractTableExpression
(
query
,
0
);
if
(
!
subquery
)
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录