mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #35799 from evillique/extract-parser-fix
Fix extract function parser
This commit is contained in:
commit
cafff71d2f
@ -504,12 +504,26 @@ namespace
|
||||
}
|
||||
|
||||
bool parseExtract(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
IParser::Pos begin = pos;
|
||||
IntervalKind interval_kind;
|
||||
|
||||
if (parseIntervalKind(pos, expected, interval_kind))
|
||||
{
|
||||
ASTPtr expr;
|
||||
|
||||
IntervalKind interval_kind;
|
||||
if (!parseIntervalKind(pos, expected, interval_kind))
|
||||
ParserKeyword s_from("FROM");
|
||||
ParserExpression elem_parser;
|
||||
|
||||
if (s_from.ignore(pos, expected) && elem_parser.parse(pos, expr, expected))
|
||||
{
|
||||
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
pos = begin;
|
||||
|
||||
ASTPtr expr_list;
|
||||
if (!ParserExpressionList(false, false).parse(pos, expr_list, expected))
|
||||
return false;
|
||||
@ -522,18 +536,6 @@ namespace
|
||||
return true;
|
||||
}
|
||||
|
||||
ParserKeyword s_from("FROM");
|
||||
if (!s_from.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
ParserExpression elem_parser;
|
||||
if (!elem_parser.parse(pos, expr, expected))
|
||||
return false;
|
||||
|
||||
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool parsePosition(IParser::Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
ASTPtr expr_list_node;
|
||||
|
@ -0,0 +1,3 @@
|
||||
1
|
||||
2
|
||||
3
|
3
tests/queries/0_stateless/02247_fix_extract_parser.sql
Normal file
3
tests/queries/0_stateless/02247_fix_extract_parser.sql
Normal file
@ -0,0 +1,3 @@
|
||||
WITH 'number: 1' as year SELECT extract(year, '\\d+');
|
||||
WITH 'number: 2' as mm SELECT extract(mm, '\\d+');
|
||||
WITH 'number: 3' as s SELECT extract(s, '\\d+');
|
Loading…
Reference in New Issue
Block a user