Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
849ca482
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
849ca482
编写于
12月 25, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
12月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18458 from spongedu/support_exists_database
support EXISTS DATABASE syntax
上级
93665349
eb95a5a0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
39 addition
and
8 deletion
+39
-8
src/Interpreters/InterpreterExistsQuery.cpp
src/Interpreters/InterpreterExistsQuery.cpp
+6
-0
src/Interpreters/InterpreterFactory.cpp
src/Interpreters/InterpreterFactory.cpp
+4
-0
src/Parsers/ParserTablePropertiesQuery.cpp
src/Parsers/ParserTablePropertiesQuery.cpp
+16
-8
src/Parsers/TablePropertiesQueriesASTs.h
src/Parsers/TablePropertiesQueriesASTs.h
+9
-0
tests/queries/0_stateless/01048_exists_query.reference
tests/queries/0_stateless/01048_exists_query.reference
+2
-0
tests/queries/0_stateless/01048_exists_query.sql
tests/queries/0_stateless/01048_exists_query.sql
+2
-0
未找到文件。
src/Interpreters/InterpreterExistsQuery.cpp
浏览文件 @
849ca482
...
...
@@ -53,6 +53,12 @@ BlockInputStreamPtr InterpreterExistsQuery::executeImpl()
result
=
DatabaseCatalog
::
instance
().
isTableExist
({
database
,
exists_query
->
table
},
context
);
}
}
else
if
((
exists_query
=
query_ptr
->
as
<
ASTExistsDatabaseQuery
>
()))
{
String
database
=
context
.
resolveDatabase
(
exists_query
->
database
);
context
.
checkAccess
(
AccessType
::
SHOW_DATABASES
,
database
);
result
=
DatabaseCatalog
::
instance
().
isDatabaseExist
(
database
);
}
else
if
((
exists_query
=
query_ptr
->
as
<
ASTExistsDictionaryQuery
>
()))
{
if
(
exists_query
->
temporary
)
...
...
src/Interpreters/InterpreterFactory.cpp
浏览文件 @
849ca482
...
...
@@ -148,6 +148,10 @@ std::unique_ptr<IInterpreter> InterpreterFactory::get(ASTPtr & query, Context &
{
return
std
::
make_unique
<
InterpreterOptimizeQuery
>
(
query
,
context
);
}
else
if
(
query
->
as
<
ASTExistsDatabaseQuery
>
())
{
return
std
::
make_unique
<
InterpreterExistsQuery
>
(
query
,
context
);
}
else
if
(
query
->
as
<
ASTExistsTableQuery
>
())
{
return
std
::
make_unique
<
InterpreterExistsQuery
>
(
query
,
context
);
...
...
src/Parsers/ParserTablePropertiesQuery.cpp
浏览文件 @
849ca482
...
...
@@ -34,15 +34,23 @@ bool ParserTablePropertiesQuery::parseImpl(Pos & pos, ASTPtr & node, Expected &
bool
temporary
=
false
;
if
(
s_exists
.
ignore
(
pos
,
expected
))
{
if
(
s_temporary
.
ignore
(
pos
,
expected
))
temporary
=
true
;
if
(
s_table
.
checkWithoutMoving
(
pos
,
expected
))
query
=
std
::
make_shared
<
ASTExistsTableQuery
>
();
else
if
(
s_dictionary
.
checkWithoutMoving
(
pos
,
expected
))
query
=
std
::
make_shared
<
ASTExistsDictionaryQuery
>
();
if
(
s_database
.
ignore
(
pos
,
expected
))
{
query
=
std
::
make_shared
<
ASTExistsDatabaseQuery
>
();
parse_only_database_name
=
true
;
}
else
query
=
std
::
make_shared
<
ASTExistsTableQuery
>
();
{
if
(
s_temporary
.
ignore
(
pos
,
expected
))
temporary
=
true
;
if
(
s_table
.
checkWithoutMoving
(
pos
,
expected
))
query
=
std
::
make_shared
<
ASTExistsTableQuery
>
();
else
if
(
s_dictionary
.
checkWithoutMoving
(
pos
,
expected
))
query
=
std
::
make_shared
<
ASTExistsDictionaryQuery
>
();
else
query
=
std
::
make_shared
<
ASTExistsTableQuery
>
();
}
}
else
if
(
s_show
.
ignore
(
pos
,
expected
))
{
...
...
src/Parsers/TablePropertiesQueriesASTs.h
浏览文件 @
849ca482
...
...
@@ -7,6 +7,14 @@
namespace
DB
{
struct
ASTExistsDatabaseQueryIDAndQueryNames
{
static
constexpr
auto
ID
=
"ExistsDatabaseQuery"
;
static
constexpr
auto
Query
=
"EXISTS DATABASE"
;
/// No temporary databases are supported, just for parsing
static
constexpr
auto
QueryTemporary
=
""
;
};
struct
ASTExistsTableQueryIDAndQueryNames
{
static
constexpr
auto
ID
=
"ExistsTableQuery"
;
...
...
@@ -51,6 +59,7 @@ struct ASTDescribeQueryExistsQueryIDAndQueryNames
static
constexpr
auto
QueryTemporary
=
"DESCRIBE TEMPORARY TABLE"
;
};
using
ASTExistsDatabaseQuery
=
ASTQueryWithTableAndOutputImpl
<
ASTExistsDatabaseQueryIDAndQueryNames
>
;
using
ASTExistsTableQuery
=
ASTQueryWithTableAndOutputImpl
<
ASTExistsTableQueryIDAndQueryNames
>
;
using
ASTExistsDictionaryQuery
=
ASTQueryWithTableAndOutputImpl
<
ASTExistsDictionaryQueryIDAndQueryNames
>
;
using
ASTShowCreateTableQuery
=
ASTQueryWithTableAndOutputImpl
<
ASTShowCreateTableQueryIDAndQueryNames
>
;
...
...
tests/queries/0_stateless/01048_exists_query.reference
浏览文件 @
849ca482
...
...
@@ -2,6 +2,8 @@
0
0
0
1
0
0
0
1
...
...
tests/queries/0_stateless/01048_exists_query.sql
浏览文件 @
849ca482
...
...
@@ -3,7 +3,9 @@ EXISTS TABLE db_01048.t_01048;
EXISTS
DICTIONARY
db_01048
.
t_01048
;
DROP
DATABASE
IF
EXISTS
db_01048
;
EXISTS
DATABASE
db_01048
;
CREATE
DATABASE
db_01048
;
EXISTS
DATABASE
db_01048
;
DROP
TABLE
IF
EXISTS
db_01048
.
t_01048
;
EXISTS
db_01048
.
t_01048
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录