Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
1bab7fc3
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,发现更多精彩内容 >>
提交
1bab7fc3
编写于
7月 12, 2017
作者:
A
Alexey Milovidov
提交者:
alexey-milovidov
7月 13, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using lexer (incomplete) [#CLICKHOUSE-2].
上级
d815b766
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
64 addition
and
71 deletion
+64
-71
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
+41
-49
dbms/src/DataStreams/ValuesRowInputStream.cpp
dbms/src/DataStreams/ValuesRowInputStream.cpp
+7
-6
dbms/src/DataTypes/DataTypeFactory.cpp
dbms/src/DataTypes/DataTypeFactory.cpp
+1
-1
dbms/src/Interpreters/DDLWorker.cpp
dbms/src/Interpreters/DDLWorker.cpp
+2
-2
dbms/src/Interpreters/executeQuery.cpp
dbms/src/Interpreters/executeQuery.cpp
+1
-1
dbms/src/Parsers/ExpressionListParsers.cpp
dbms/src/Parsers/ExpressionListParsers.cpp
+2
-2
dbms/src/Parsers/ExpressionListParsers.h
dbms/src/Parsers/ExpressionListParsers.h
+3
-0
dbms/src/Parsers/ParserAlterQuery.cpp
dbms/src/Parsers/ParserAlterQuery.cpp
+1
-1
dbms/src/Parsers/ParserCase.cpp
dbms/src/Parsers/ParserCase.cpp
+1
-1
dbms/src/Parsers/ParserKillQueryQuery.cpp
dbms/src/Parsers/ParserKillQueryQuery.cpp
+1
-1
dbms/src/Parsers/ParserSelectQuery.cpp
dbms/src/Parsers/ParserSelectQuery.cpp
+1
-1
dbms/src/Storages/ColumnsDescription.cpp
dbms/src/Storages/ColumnsDescription.cpp
+3
-6
未找到文件。
dbms/src/AggregateFunctions/AggregateFunctionSequenceMatch.h
浏览文件 @
1bab7fc3
...
...
@@ -4,11 +4,7 @@
#include <DataTypes/DataTypeDateTime.h>
#include <DataTypes/DataTypesNumber.h>
#include <Columns/ColumnsNumber.h>
#include <Parsers/CommonParsers.h>
#include <ext/range.h>
#include <boost/range/iterator_range_core.hpp>
#include <Parsers/ExpressionElementParsers.h>
#include <Parsers/ASTLiteral.h>
#include <Common/PODArray.h>
#include <IO/ReadHelpers.h>
#include <IO/WriteHelpers.h>
...
...
@@ -164,23 +160,20 @@ public:
if
(
!
sufficientArgs
(
arg_count
))
throw
Exception
{
"Aggregate function "
+
getName
()
+
" requires at least 3 arguments."
,
ErrorCodes
::
TOO_LESS_ARGUMENTS_FOR_FUNCTION
};
ErrorCodes
::
TOO_LESS_ARGUMENTS_FOR_FUNCTION
};
if
(
arg_count
-
1
>
Data
::
max_events
)
throw
Exception
{
"Aggregate function "
+
getName
()
+
" supports up to "
+
std
::
to_string
(
Data
::
max_events
)
+
" event arguments."
,
ErrorCodes
::
TOO_MUCH_ARGUMENTS_FOR_FUNCTION
};
ErrorCodes
::
TOO_MUCH_ARGUMENTS_FOR_FUNCTION
};
const
auto
time_arg
=
arguments
.
front
().
get
();
if
(
!
typeid_cast
<
const
DataTypeDateTime
*>
(
time_arg
))
throw
Exception
{
"Illegal type "
+
time_arg
->
getName
()
+
" of first argument of aggregate function "
+
getName
()
+
", must be DateTime"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
for
(
const
auto
i
:
ext
::
range
(
1
,
arg_count
))
{
...
...
@@ -189,8 +182,7 @@ public:
throw
Exception
{
"Illegal type "
+
cond_arg
->
getName
()
+
" of argument "
+
toString
(
i
+
1
)
+
" of aggregate function "
+
getName
()
+
", must be UInt8"
,
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
ErrorCodes
::
ILLEGAL_TYPE_OF_ARGUMENT
};
}
parsePattern
();
...
...
@@ -275,52 +267,51 @@ private:
actions
.
clear
();
actions
.
emplace_back
(
PatternActionType
::
KleeneStar
);
ParserString
special_open_p
(
"(?"
);
ParserString
special_close_p
(
")"
);
ParserString
t_p
(
"t"
);
ParserString
less_or_equal_p
(
"<="
);
ParserString
less_p
(
"<"
);
ParserString
greater_or_equal_p
(
">="
);
ParserString
greater_p
(
">"
);
ParserString
dot_closure_p
(
".*"
);
ParserString
dot_p
(
"."
);
ParserNumber
number_p
;
const
char
*
pos
=
pattern
.
data
();
const
auto
begin
=
pos
;
const
auto
end
=
pos
+
pattern
.
size
();
ASTPtr
node
;
decltype
(
pos
)
max_parsed_pos
{};
Expected
expected
;
const
char
*
begin
=
pos
;
const
char
*
end
=
pos
+
pattern
.
size
();
const
auto
throw_exception
=
[
&
]
(
const
std
::
string
&
msg
)
auto
throw_exception
=
[
&
]
(
const
std
::
string
&
msg
)
{
throw
Exception
{
msg
+
" '"
+
std
::
string
(
pos
,
end
)
+
"' at position "
+
std
::
to_string
(
pos
-
begin
),
ErrorCodes
::
SYNTAX_ERROR
};
};
auto
match
=
[
&
](
const
char
*
str
)
{
size_t
length
=
strlen
(
str
);
if
(
pos
+
length
<
end
&&
0
==
memcmp
(
pos
,
str
,
length
))
{
pos
+=
length
;
return
true
;
}
return
false
;
};
while
(
pos
<
end
)
{
if
(
special_open_p
.
ignore
(
pos
,
end
))
if
(
match
(
"(?"
))
{
if
(
t_p
.
ignore
(
pos
,
end
))
if
(
match
(
"t"
))
{
PatternActionType
type
;
if
(
less_or_equal_p
.
ignore
(
pos
,
end
))
if
(
match
(
"<="
))
type
=
PatternActionType
::
TimeLessOrEqual
;
else
if
(
less_p
.
ignore
(
pos
,
end
))
else
if
(
match
(
"<"
))
type
=
PatternActionType
::
TimeLess
;
else
if
(
greater_or_equal_p
.
ignore
(
pos
,
end
))
else
if
(
match
(
">="
))
type
=
PatternActionType
::
TimeGreaterOrEqual
;
else
if
(
greater_p
.
ignore
(
pos
,
end
))
else
if
(
match
(
">"
))
type
=
PatternActionType
::
TimeGreater
;
else
throw_exception
(
"Unknown time condition"
);
if
(
!
number_p
.
parse
(
pos
,
node
,
expected
))
UInt64
duration
=
0
;
auto
prev_pos
=
pos
;
pos
=
tryReadIntText
(
duration
,
pos
,
end
);
if
(
pos
==
prev_pos
)
throw_exception
(
"Could not parse number"
);
if
(
actions
.
back
().
type
!=
PatternActionType
::
SpecificEvent
&&
...
...
@@ -328,32 +319,33 @@ private:
actions
.
back
().
type
!=
PatternActionType
::
KleeneStar
)
throw
Exception
{
"Temporal condition should be preceeded by an event condition"
,
ErrorCodes
::
BAD_ARGUMENTS
};
ErrorCodes
::
BAD_ARGUMENTS
};
actions
.
emplace_back
(
type
,
typeid_cast
<
const
ASTLiteral
&>
(
*
node
).
value
.
safeGet
<
UInt64
>
()
);
actions
.
emplace_back
(
type
,
duration
);
}
else
if
(
number_p
.
parse
(
pos
,
node
,
expected
))
else
{
const
auto
event_number
=
typeid_cast
<
const
ASTLiteral
&>
(
*
node
).
value
.
safeGet
<
UInt64
>
();
UInt64
event_number
=
0
;
auto
prev_pos
=
pos
;
pos
=
tryReadIntText
(
event_number
,
pos
,
end
);
if
(
pos
==
prev_pos
)
throw_exception
(
"Could not parse number"
);
if
(
event_number
>
arg_count
-
1
)
throw
Exception
{
"Event number "
+
std
::
to_string
(
event_number
)
+
" is out of range"
,
ErrorCodes
::
BAD_ARGUMENTS
};
ErrorCodes
::
BAD_ARGUMENTS
};
actions
.
emplace_back
(
PatternActionType
::
SpecificEvent
,
event_number
-
1
);
}
else
throw_exception
(
"Unexpected special sequence"
);
if
(
!
special_close_p
.
ignore
(
pos
,
end
))
if
(
!
match
(
")"
))
throw_exception
(
"Expected closing parenthesis, found"
);
}
else
if
(
dot_closure_p
.
ignore
(
pos
,
end
))
else
if
(
match
(
".*"
))
actions
.
emplace_back
(
PatternActionType
::
KleeneStar
);
else
if
(
dot_p
.
ignore
(
pos
,
end
))
else
if
(
match
(
"."
))
actions
.
emplace_back
(
PatternActionType
::
AnyEvent
);
else
throw_exception
(
"Could not parse pattern, unexpected starting symbol"
);
...
...
dbms/src/DataStreams/ValuesRowInputStream.cpp
浏览文件 @
1bab7fc3
#include <IO/ReadHelpers.h>
#include <Interpreters/evaluateConstantExpression.h>
#include <Interpreters/convertFieldToType.h>
#include <Parsers/TokenIterator.h>
#include <Parsers/ExpressionListParsers.h>
#include <DataStreams/ValuesRowInputStream.h>
#include <DataTypes/DataTypeArray.h>
...
...
@@ -85,7 +86,7 @@ bool ValuesRowInputStream::read(Block & block)
||
e
.
code
()
==
ErrorCodes
::
CANNOT_PARSE_DATETIME
||
e
.
code
()
==
ErrorCodes
::
CANNOT_READ_ARRAY_FROM_TEXT
)
{
/// TODO
Performance if the expression does not fit entirely to the end of
the buffer.
/// TODO
Case when the expression does not fit entirely in
the buffer.
/// If the beginning of the value is no longer in the buffer.
if
(
istr
.
count
()
-
istr
.
offset
()
!=
prev_istr_bytes
)
...
...
@@ -96,18 +97,18 @@ bool ValuesRowInputStream::read(Block & block)
IDataType
&
type
=
*
block
.
safeGetByPosition
(
i
).
type
;
IParser
::
Pos
pos
=
prev_istr_position
;
Expected
expected
=
""
;
IParser
::
Pos
max_parsed_pos
=
pos
;
Tokens
tokens
(
prev_istr_position
,
istr
.
buffer
().
end
());
TokenIterator
token_iterator
(
tokens
);
ASTPtr
ast
;
if
(
!
parser
.
parse
(
pos
,
istr
.
buffer
().
end
(),
ast
,
max_parsed_pos
,
expected
))
if
(
!
parser
.
parse
(
token_iterator
,
ast
,
expected
))
throw
Exception
(
"Cannot parse expression of type "
+
type
.
getName
()
+
" here: "
+
String
(
prev_istr_position
,
std
::
min
(
SHOW_CHARS_ON_SYNTAX_ERROR
,
istr
.
buffer
().
end
()
-
prev_istr_position
)),
ErrorCodes
::
SYNTAX_ERROR
);
istr
.
position
()
=
const_cast
<
char
*>
(
max_parsed_pos
);
istr
.
position
()
=
const_cast
<
char
*>
(
token_iterator
->
begin
);
std
::
pair
<
Field
,
DataTypePtr
>
value_raw
=
evaluateConstantExpression
(
ast
,
context
);
Field
value
=
convertFieldToType
(
value_raw
.
first
,
type
,
value_raw
.
second
.
get
());
...
...
dbms/src/DataTypes/DataTypeFactory.cpp
浏览文件 @
1bab7fc3
...
...
@@ -71,7 +71,7 @@ DataTypeFactory::DataTypeFactory()
template
<
typename
DataTypeEnum
>
inline
DataTypePtr
parseEnum
(
const
String
&
name
,
const
String
&
base_name
,
const
String
&
parameters
)
{
ParserList
parser
{
std
::
make_unique
<
ParserEnumElement
>
(),
std
::
make_unique
<
Parser
String
>
(
","
),
false
};
ParserList
parser
{
std
::
make_unique
<
ParserEnumElement
>
(),
std
::
make_unique
<
Parser
Token
>
(
TokenType
::
Comma
),
false
};
ASTPtr
elements
=
parseQuery
(
parser
,
parameters
.
data
(),
parameters
.
data
()
+
parameters
.
size
(),
"parameters for enum type "
+
name
);
...
...
dbms/src/Interpreters/DDLWorker.cpp
浏览文件 @
1bab7fc3
...
...
@@ -263,9 +263,9 @@ void DDLWorker::processTask(const DDLLogEntry & node, const std::string & node_n
{
ASTPtr
query_ast
;
{
ParserQuery
parser_query
;
String
description
;
const
char
*
begin
=
&
node
.
query
.
front
();
ParserQuery
parser_query
(
begin
+
node
.
query
.
size
());
String
description
;
query_ast
=
parseQuery
(
parser_query
,
begin
,
begin
+
node
.
query
.
size
(),
description
);
}
...
...
dbms/src/Interpreters/executeQuery.cpp
浏览文件 @
1bab7fc3
...
...
@@ -131,7 +131,7 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
const
Settings
&
settings
=
context
.
getSettingsRef
();
ParserQuery
parser
;
ParserQuery
parser
(
end
)
;
ASTPtr
ast
;
size_t
query_size
;
size_t
max_query_size
=
settings
.
max_query_size
;
...
...
dbms/src/Parsers/ExpressionListParsers.cpp
浏览文件 @
1bab7fc3
...
...
@@ -533,13 +533,13 @@ bool ParserTupleElementExpression::parseImpl(Pos & pos, ASTPtr & node, Expected
ParserExpressionWithOptionalAlias
::
ParserExpressionWithOptionalAlias
(
bool
allow_alias_without_as_keyword
)
:
impl
(
std
::
make_unique
<
ParserWithOptionalAlias
>
(
std
::
make_unique
<
Parser
Lambda
Expression
>
(),
allow_alias_without_as_keyword
))
:
impl
(
std
::
make_unique
<
ParserWithOptionalAlias
>
(
std
::
make_unique
<
ParserExpression
>
(),
allow_alias_without_as_keyword
))
{
}
ParserExpressionInCastExpression
::
ParserExpressionInCastExpression
(
bool
allow_alias_without_as_keyword
)
:
impl
(
std
::
make_unique
<
ParserCastExpressionWithOptionalAlias
>
(
std
::
make_unique
<
Parser
Lambda
Expression
>
(),
allow_alias_without_as_keyword
))
:
impl
(
std
::
make_unique
<
ParserCastExpressionWithOptionalAlias
>
(
std
::
make_unique
<
ParserExpression
>
(),
allow_alias_without_as_keyword
))
{
}
...
...
dbms/src/Parsers/ExpressionListParsers.h
浏览文件 @
1bab7fc3
...
...
@@ -305,6 +305,9 @@ protected:
};
using
ParserExpression
=
ParserLambdaExpression
;
class
ParserExpressionWithOptionalAlias
:
public
IParserBase
{
public:
...
...
dbms/src/Parsers/ParserAlterQuery.cpp
浏览文件 @
1bab7fc3
...
...
@@ -217,7 +217,7 @@ bool ParserAlterQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
else
if
(
s_reshard
.
ignore
(
pos
,
expected
))
{
ParserList
weighted_zookeeper_paths_p
(
std
::
make_unique
<
ParserWeightedZooKeeperPath
>
(),
std
::
make_unique
<
ParserToken
>
(
TokenType
::
Comma
),
false
);
ParserExpression
WithOptionalAlias
parser_sharding_key_expr
(
false
);
ParserExpression
parser_sharding_key_expr
(
false
);
ParserStringLiteral
parser_coordinator
;
if
(
s_copy
.
ignore
(
pos
,
expected
))
...
...
dbms/src/Parsers/ParserCase.cpp
浏览文件 @
1bab7fc3
...
...
@@ -17,7 +17,7 @@ bool ParserCase::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
ParserKeyword
s_then
{
"THEN"
};
ParserKeyword
s_else
{
"ELSE"
};
ParserKeyword
s_end
{
"END"
};
ParserExpression
WithOptionalAlias
p_expr
{
false
};
ParserExpression
p_expr
{
false
};
if
(
!
s_case
.
parse
(
pos
,
node
,
expected
))
{
...
...
dbms/src/Parsers/ParserKillQueryQuery.cpp
浏览文件 @
1bab7fc3
...
...
@@ -27,7 +27,7 @@ bool ParserKillQueryQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expect
if
(
!
ParserKeyword
{
"WHERE"
}.
ignore
(
pos
,
expected
))
return
false
;
ParserExpression
WithOptionalAlias
p_where_expression
(
false
);
ParserExpression
p_where_expression
(
false
);
if
(
!
p_where_expression
.
parse
(
pos
,
query
->
where_expression
,
expected
))
return
false
;
...
...
dbms/src/Parsers/ParserSelectQuery.cpp
浏览文件 @
1bab7fc3
...
...
@@ -44,7 +44,7 @@ bool ParserSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
ParserNotEmptyExpressionList
exp_list
(
false
);
ParserNotEmptyExpressionList
exp_list_for_select_clause
(
true
);
/// Allows aliases without AS keyword.
ParserExpression
WithOptionalAlias
exp_elem
(
false
);
ParserExpression
exp_elem
(
false
);
ParserOrderByExpressionList
order_list
;
/// SELECT [DISTINCT] expr list
...
...
dbms/src/Storages/ColumnsDescription.cpp
浏览文件 @
1bab7fc3
#include <Parsers/ExpressionListParsers.h>
#include <Parsers/parseQuery.h>
#include <Parsers/queryToString.h>
#include <IO/WriteBuffer.h>
#include <IO/WriteHelpers.h>
...
...
@@ -71,7 +72,7 @@ ColumnsDescription<true> ColumnsDescription<true>::parse(const String & str)
readText
(
count
,
buf
);
assertString
(
" columns:
\n
"
,
buf
);
Parser
TernaryOperatorExpression
expr_parser
;
Parser
ExpressionWithOptionalAlias
expr_parser
(
false
)
;
const
DataTypeFactory
&
data_type_factory
=
DataTypeFactory
::
instance
();
ColumnsDescription
<
true
>
result
{};
...
...
@@ -102,13 +103,9 @@ ColumnsDescription<true> ColumnsDescription<true>::parse(const String & str)
readText
(
default_expr_str
,
buf
);
assertChar
(
'\n'
,
buf
);
ASTPtr
default_expr
;
Expected
expected
{};
const
char
*
begin
=
default_expr_str
.
data
();
const
auto
end
=
begin
+
default_expr_str
.
size
();
const
char
*
max_parsed_pos
=
begin
;
if
(
!
expr_parser
.
parse
(
begin
,
end
,
default_expr
,
max_parsed_pos
,
expected
))
throw
Exception
{
"Could not parse default expression"
,
DB
::
ErrorCodes
::
CANNOT_PARSE_TEXT
};
ASTPtr
default_expr
=
parseQuery
(
expr_parser
,
begin
,
end
,
"default expression"
);
if
(
ColumnDefaultType
::
Default
==
default_type
)
result
.
columns
.
emplace_back
(
column_name
,
std
::
move
(
type
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录