mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Fixed tests
This commit is contained in:
parent
c9a1605b1e
commit
01e09ba44e
@ -593,7 +593,6 @@ namespace
|
|||||||
/// First try to match with date extract operator EXTRACT(part FROM date)
|
/// First try to match with date extract operator EXTRACT(part FROM date)
|
||||||
/// Then with function extract(haystack, pattern)
|
/// Then with function extract(haystack, pattern)
|
||||||
|
|
||||||
IParser::Pos begin = pos;
|
|
||||||
IntervalKind interval_kind;
|
IntervalKind interval_kind;
|
||||||
|
|
||||||
if (parseIntervalKind(pos, expected, interval_kind))
|
if (parseIntervalKind(pos, expected, interval_kind))
|
||||||
@ -608,9 +607,9 @@ namespace
|
|||||||
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
node = makeASTFunction(interval_kind.toNameOfFunctionExtractTimePart(), expr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
pos = begin;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ASTPtr expr_list;
|
ASTPtr expr_list;
|
||||||
if (!ParserExpressionList(true /*allow_alias_without_as_keyword*/).parse(pos, expr_list, expected))
|
if (!ParserExpressionList(true /*allow_alias_without_as_keyword*/).parse(pos, expr_list, expected))
|
||||||
@ -758,7 +757,22 @@ namespace
|
|||||||
if (!ParserExpressionWithOptionalAlias(true /*allow_alias_without_as_keyword*/).parse(pos, right_node, expected))
|
if (!ParserExpressionWithOptionalAlias(true /*allow_alias_without_as_keyword*/).parse(pos, right_node, expected))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
node = makeASTFunction("dateDiff", std::make_shared<ASTLiteral>(interval_kind.toDateDiffUnit()), left_node, right_node);
|
ASTPtr timezone_node;
|
||||||
|
|
||||||
|
if (pos->type == TokenType::Comma)
|
||||||
|
{
|
||||||
|
/// Optional timezone
|
||||||
|
++pos;
|
||||||
|
|
||||||
|
if (!ParserExpressionWithOptionalAlias(true /*allow_alias_without_as_keyword*/).parse(pos, timezone_node, expected))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto interval_literal = std::make_shared<ASTLiteral>(interval_kind.toDateDiffUnit());
|
||||||
|
if (timezone_node)
|
||||||
|
node = makeASTFunction("dateDiff", std::move(interval_literal), std::move(left_node), std::move(right_node), std::move(timezone_node));
|
||||||
|
else
|
||||||
|
node = makeASTFunction("dateDiff", std::move(interval_literal), std::move(left_node), std::move(right_node));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -54,3 +54,7 @@ bc a abca
|
|||||||
1 2019-05-05 2019-05-06
|
1 2019-05-05 2019-05-06
|
||||||
1 2019-05-05 2019-05-06
|
1 2019-05-05 2019-05-06
|
||||||
1 2019-05-05 2019-05-06
|
1 2019-05-05 2019-05-06
|
||||||
|
1 2019-05-05 2019-05-06
|
||||||
|
1 2019-05-05 2019-05-06
|
||||||
|
1 2019-05-05 2019-05-06
|
||||||
|
1 2019-05-05 2019-05-06
|
||||||
|
@ -110,8 +110,12 @@ SELECT dateSub(DAY, 1 arg_1, toDate('2019-05-05') arg_2), arg_1, arg_2;
|
|||||||
|
|
||||||
SELECT dateDiff(DAY, toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2), arg_1, arg_2;
|
SELECT dateDiff(DAY, toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2), arg_1, arg_2;
|
||||||
SELECT dateDiff(DAY, toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2), arg_1, arg_2;
|
SELECT dateDiff(DAY, toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2), arg_1, arg_2;
|
||||||
|
SELECT dateDiff(DAY, toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2, 'UTC'), arg_1, arg_2;
|
||||||
|
SELECT dateDiff(DAY, toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2, 'UTC'), arg_1, arg_2;
|
||||||
|
|
||||||
-- dateDiff('unit', startdate, enddate, [timezone])
|
-- dateDiff('unit', startdate, enddate, [timezone])
|
||||||
|
|
||||||
SELECT dateDiff('DAY', toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2), arg_1, arg_2;
|
SELECT dateDiff('DAY', toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2), arg_1, arg_2;
|
||||||
SELECT dateDiff('DAY', toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2), arg_1, arg_2;
|
SELECT dateDiff('DAY', toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2), arg_1, arg_2;
|
||||||
|
SELECT dateDiff('DAY', toDate('2019-05-05') AS arg_1, toDate('2019-05-06') AS arg_2, 'UTC'), arg_1, arg_2;
|
||||||
|
SELECT dateDiff('DAY', toDate('2019-05-05') arg_1, toDate('2019-05-06') arg_2, 'UTC'), arg_1, arg_2;
|
||||||
|
Loading…
Reference in New Issue
Block a user