Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
eb620b63
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,发现更多精彩内容 >>
未验证
提交
eb620b63
编写于
5月 25, 2020
作者:
A
alexey-milovidov
提交者:
GitHub
5月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11182 from 4ertus2/some
Remove stale unit-test
上级
51ffcff7
6cc43b74
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1 addition
and
133 deletion
+1
-133
programs/CMakeLists.txt
programs/CMakeLists.txt
+1
-1
src/Interpreters/tests/CMakeLists.txt
src/Interpreters/tests/CMakeLists.txt
+0
-4
src/Interpreters/tests/expression_analyzer.cpp
src/Interpreters/tests/expression_analyzer.cpp
+0
-128
未找到文件。
programs/CMakeLists.txt
浏览文件 @
eb620b63
...
...
@@ -207,7 +207,7 @@ if (TARGET clickhouse-server AND TARGET copy-headers)
endif
()
if
(
ENABLE_TESTS AND USE_GTEST
)
set
(
CLICKHOUSE_ALL_TESTS_TARGETS local_date_time_comparison unit_tests_libcommon unit_tests_dbms hashing_write_buffer hashing_read_buffer in_join_subqueries_preprocessor
expression_analyzer
)
set
(
CLICKHOUSE_ALL_TESTS_TARGETS local_date_time_comparison unit_tests_libcommon unit_tests_dbms hashing_write_buffer hashing_read_buffer in_join_subqueries_preprocessor
)
add_custom_target
(
clickhouse-tests ALL DEPENDS
${
CLICKHOUSE_ALL_TESTS_TARGETS
}
)
add_dependencies
(
clickhouse-bundle clickhouse-tests
)
endif
()
src/Interpreters/tests/CMakeLists.txt
浏览文件 @
eb620b63
...
...
@@ -51,10 +51,6 @@ add_executable (in_join_subqueries_preprocessor in_join_subqueries_preprocessor.
target_link_libraries
(
in_join_subqueries_preprocessor PRIVATE dbms clickhouse_parsers
)
add_check
(
in_join_subqueries_preprocessor
)
add_executable
(
expression_analyzer expression_analyzer.cpp
)
target_link_libraries
(
expression_analyzer PRIVATE dbms clickhouse_storages_system clickhouse_parsers clickhouse_common_io
)
add_check
(
expression_analyzer
)
add_executable
(
users users.cpp
)
target_link_libraries
(
users PRIVATE dbms clickhouse_common_config
)
...
...
src/Interpreters/tests/expression_analyzer.cpp
已删除
100644 → 0
浏览文件 @
51ffcff7
#include <DataTypes/DataTypesNumber.h>
#include <Storages/System/StorageSystemOne.h>
#include <Storages/System/StorageSystemNumbers.h>
#include <Databases/DatabaseMemory.h>
#include <Parsers/ParserSelectQuery.h>
#include <Parsers/parseQuery.h>
#include <Interpreters/Context.h>
#include <Interpreters/SyntaxAnalyzer.h>
#include <IO/WriteBufferFromFileDescriptor.h>
#include <IO/ReadBufferFromFileDescriptor.h>
#include <vector>
#include <unordered_map>
#include <iostream>
using
namespace
DB
;
namespace
DB
{
namespace
ErrorCodes
{
extern
const
int
SYNTAX_ERROR
;
}
}
struct
TestEntry
{
String
query
;
std
::
unordered_map
<
String
,
String
>
expected_aliases
;
/// alias -> AST.getID()
NamesAndTypesList
source_columns
=
{};
bool
check
(
const
Context
&
context
)
{
ASTPtr
ast
=
parse
(
query
);
auto
res
=
SyntaxAnalyzer
(
context
).
analyze
(
ast
,
source_columns
);
return
checkAliases
(
*
res
);
}
private:
bool
checkAliases
(
const
SyntaxAnalyzerResult
&
res
)
{
for
(
const
auto
&
alias
:
res
.
aliases
)
{
const
String
&
alias_name
=
alias
.
first
;
if
(
expected_aliases
.
count
(
alias_name
)
==
0
||
expected_aliases
[
alias_name
]
!=
alias
.
second
->
getID
())
{
std
::
cout
<<
"unexpected alias: "
<<
alias_name
<<
' '
<<
alias
.
second
->
getID
()
<<
std
::
endl
;
return
false
;
}
else
expected_aliases
.
erase
(
alias_name
);
}
if
(
!
expected_aliases
.
empty
())
{
std
::
cout
<<
"missing aliases: "
<<
expected_aliases
.
size
()
<<
std
::
endl
;
return
false
;
}
return
true
;
}
static
ASTPtr
parse
(
const
std
::
string
&
query
)
{
ParserSelectQuery
parser
;
std
::
string
message
;
const
auto
*
text
=
query
.
data
();
if
(
ASTPtr
ast
=
tryParseQuery
(
parser
,
text
,
text
+
query
.
size
(),
message
,
false
,
""
,
false
,
0
,
0
))
return
ast
;
throw
Exception
(
message
,
ErrorCodes
::
SYNTAX_ERROR
);
}
};
int
main
()
{
std
::
vector
<
TestEntry
>
queries
=
{
{
"SELECT number AS n FROM system.numbers LIMIT 0"
,
{{
"n"
,
"Identifier_number"
}},
{
NameAndTypePair
(
"number"
,
std
::
make_shared
<
DataTypeUInt64
>
())
}
},
{
"SELECT number AS n FROM system.numbers LIMIT 0"
,
{{
"n"
,
"Identifier_number"
}}
}
};
SharedContextHolder
shared_context
=
Context
::
createShared
();
Context
context
=
Context
::
createGlobal
(
shared_context
.
get
());
context
.
makeGlobalContext
();
auto
system_database
=
std
::
make_shared
<
DatabaseMemory
>
(
"system"
);
DatabaseCatalog
::
instance
().
attachDatabase
(
"system"
,
system_database
);
//context.setCurrentDatabase("system");
system_database
->
attachTable
(
"one"
,
StorageSystemOne
::
create
(
"one"
),
{});
system_database
->
attachTable
(
"numbers"
,
StorageSystemNumbers
::
create
(
StorageID
(
"system"
,
"numbers"
),
false
),
{});
size_t
success
=
0
;
for
(
auto
&
entry
:
queries
)
{
try
{
if
(
entry
.
check
(
context
))
{
++
success
;
std
::
cout
<<
"[OK] "
<<
entry
.
query
<<
std
::
endl
;
}
else
std
::
cout
<<
"[Failed] "
<<
entry
.
query
<<
std
::
endl
;
}
catch
(
Exception
&
e
)
{
std
::
cout
<<
"[Error] "
<<
entry
.
query
<<
std
::
endl
<<
e
.
displayText
()
<<
std
::
endl
;
}
}
return
success
!=
queries
.
size
();
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录