@@ -99,7 +99,7 @@ bool DatetimePart::convertImpl(String & out, IParser::Pos & pos)
99
99
}
100
100
String format;
101
101
102
- if (part == " YEAR" )
102
+ if (part == " YEAR" )
103
103
format = " %G" ;
104
104
else if (part == " QUARTER" )
105
105
format = " %Q" ;
@@ -325,7 +325,7 @@ bool FormatDateTime::convertImpl(String & out, IParser::Pos & pos)
325
325
i = i + arg.size ();
326
326
}
327
327
}
328
- if (decimal > 0 && formatspecifier.find (' .' )!=String::npos)
328
+ if (decimal > 0 && formatspecifier.find (' .' )!=String::npos)
329
329
{
330
330
331
331
out = std::format (" concat("
@@ -416,13 +416,12 @@ bool FormatTimeSpan::convertImpl(String & out, IParser::Pos & pos)
416
416
if (decimal > 0 )
417
417
{
418
418
if (format.substr (format.length ()- decimal -1 , 1 ) == last_delim)
419
- out = std::format (" concat(substring(toString(formatDateTime( toDateTime64({0},9,'UTC') ,'{1}')),1, length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) - position( reverse(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}'))),'{4 }')+1),substring(SUBSTRING(toString(toDateTime64({0},9,'UTC')),position(toString(toDateTime64({0},9,'UTC')),'.')+1),1,{2}),substring(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}')),position( toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}')),'{4}'),length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) ))" , datetime,formatspecifier,decimal,last_delim);
419
+ out = std::format (" concat(substring(toString(formatDateTime( toDateTime64({0},9,'UTC') ,'{1}')),1, length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) - position( reverse(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}'))),'{3 }')+1),substring(SUBSTRING(toString(toDateTime64({0},9,'UTC')),position(toString(toDateTime64({0},9,'UTC')),'.')+1),1,{2}))" , datetime,formatspecifier,decimal,last_delim);
420
420
else
421
- out = std::format (" concat(substring(toString(formatDateTime( toDateTime64({0},9,'UTC') ,'{1}')),1, length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) - position( reverse(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}'))),'{4 }')),substring(SUBSTRING(toString(toDateTime64({0},9,'UTC')),position(toString(toDateTime64({0},9,'UTC')),'.')+1),1,{2}),substring(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}')),position( toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}')),'{4}'),length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) ))" , datetime,formatspecifier,decimal,last_delim);
421
+ out = std::format (" concat(substring(toString(formatDateTime( toDateTime64({0},9,'UTC') ,'{1}')),1, length(toString(formatDateTime( toDateTime64({0},9,'UTC'),'{1}'))) - position( reverse(toString(formatDateTime(toDateTime64({0},9,'UTC'),'{1}'))),'{3 }')),substring(SUBSTRING(toString(toDateTime64({0},9,'UTC')),position(toString(toDateTime64({0},9,'UTC')),'.')+1),1,{2}))" , datetime,formatspecifier,decimal,last_delim);
422
422
}
423
423
else
424
424
out = std::format (" formatDateTime(toDateTime64({0},9,'UTC'),'{1}')" , datetime,formatspecifier);
425
-
426
425
}
427
426
else
428
427
{
@@ -473,7 +472,7 @@ bool MakeTimeSpan::convertImpl(String & out, IParser::Pos & pos)
473
472
{
474
473
String arg = getConvertedArgument (fn_name, pos);
475
474
args.insert (args.begin (),arg);
476
- if (pos->type == TokenType::Comma)
475
+ if (pos->type == TokenType::Comma)
477
476
++pos;
478
477
++arg_count;
479
478
}
@@ -540,7 +539,7 @@ bool MakeDateTime::convertImpl(String & out, IParser::Pos & pos)
540
539
while (!pos->isEnd () && pos->type != TokenType::ClosingRoundBracket)
541
540
{
542
541
String arg = getConvertedArgument (fn_name, pos);
543
- if (pos->type == TokenType::Comma)
542
+ if (pos->type == TokenType::Comma)
544
543
++pos;
545
544
arguments = arguments + arg + " ," ;
546
545
++arg_count;
@@ -705,15 +704,11 @@ bool UnixTimeSecondsToDateTime::convertImpl(String & out, IParser::Pos & pos)
705
704
706
705
++pos;
707
706
if (pos->type == TokenType::QuotedIdentifier || pos->type == TokenType::StringLiteral)
708
- throw Exception (" String Literal is not accepted. " + fn_name + " accepts only long, int and double " , ErrorCodes::BAD_ARGUMENTS);
707
+ throw Exception (fn_name + " accepts only long, int and double type of arguments " , ErrorCodes::BAD_ARGUMENTS);
709
708
710
709
String expression = getConvertedArgument (fn_name, pos);
711
710
712
- if (std::any_of (expression.begin (), expression.end (), ::isalpha))
713
- throw Exception (" String Literal is not accepted." + fn_name + " accepts only long, int and double " , ErrorCodes::BAD_ARGUMENTS);
714
-
715
- std::remove (expression.begin (), expression.end (), ' ' );
716
- out = std::format (" multiIf(toTypeName({0}) == 'String' or toTypeName({0}) == 'UUID' or toTypeName({0}) == 'DateTime64(3)' or toTypeName({0}) == 'DateTime64(6), or toTypeName({0}) == 'DateTime64(9) , 'Only Accepted arguments are float , int and double', toString(toDateTime64(abs({0}) , 9,'UTC')))" , expression);
711
+ out = std::format (" toDateTime64({0} , 9,'UTC')" , expression);
717
712
718
713
return true ;
719
714
}
0 commit comments