Skip to content

Commit

Permalink
Merge pull request #85 from ClibMouse/feature/kql-functional-tests-5
Browse files Browse the repository at this point in the history
Feature/kql functional tests 5
  • Loading branch information
ltrk2 authored Sep 28, 2022
2 parents ce579ed + 54d515a commit 8a9a475
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Parsers/Kusto/KustoFunctions/KQLDataTypeFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool DatatypeInt::convertImpl(String & out, IParser::Pos & pos)

++pos;
if (pos->type == TokenType::QuotedIdentifier || pos->type == TokenType::StringLiteral)
throw Exception("String is not parsed as double literal", ErrorCodes::BAD_ARGUMENTS);
throw Exception("String is not parsed as int literal.", ErrorCodes::BAD_ARGUMENTS);
else
{
auto arg = getConvertedArgument(fn_name, pos);
Expand Down
13 changes: 11 additions & 2 deletions tests/queries/0_stateless/02366_kql_datatype.reference
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,32 @@ inf
2014-05-25 08:20:03.123456000
2014-11-08 15:55:55.123456000
-- time
1216984.12345
45055.123
86400
-86400
6e-9
6e-10
6e-7
-- guid
\N
-- timespan (time)
172800
5400
1800
10
0.1
0.1
0.00001
1e-10
1e-7
3
1120343
-- null
1
\N \N \N \N \N
-- decimal
\N
123.345
100000
-- dynamic
\N
1
Expand Down Expand Up @@ -88,10 +93,14 @@ true
-- make_timespan()
01:12:00 01:12:30 1.12:30:55
-- totimespan()
1e-7
60
\N
1120343
-- tolong()
123
\N
-- todecimal()
123.345
\N
\N
33 changes: 20 additions & 13 deletions tests/queries/0_stateless/02366_kql_datatype.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ print bool(null);
print '-- int';
print int(123);
print int(null);
print int('4'); -- { clientError BAD_ARGUMENTS }
print '-- long';
print long(123);
print long(0xff);
Expand All @@ -19,6 +20,7 @@ print real(null);
print real(nan);
print real(+inf);
print real(-inf);
print double('4.2'); -- { clientError BAD_ARGUMENTS }
print '-- datetime';
print datetime(2015-12-31 23:59:59.9);
print datetime(2015-12-31);
Expand All @@ -29,32 +31,34 @@ print datetime('2014-11-08');
print datetime(null);
print datetime('2014-05-25T08:20:03.123456Z');
print datetime('2014-11-08 15:55:55.123456Z');
print '-- time'
print '-- time';
print time('14.02:03:04.12345');
print time('12:30:55.123');
print time(1d);
print time(-1d);
print time(6nanoseconds);
print time(6tick);
print '-- guid'
print guid(74be27de-1e4e-49d9-b579-fe0b331d3642)
-- print guid(null)
print guid(74be27de-1e4e-49d9-b579-fe0b331d3642);
print guid(null);
print '-- timespan (time)';
print timespan(2d); -- 2 days
print timespan(1.5h); -- 1.5 hour
print timespan(30m); -- 30 minutes
print timespan(10s); -- 10 seconds
print timespan(0.1s); -- 0.1 second
print timespan(100ms); -- 100 millisecond
print timespan(2d); -- 2 days
print timespan(1.5h); -- 1.5 hour
print timespan(30m); -- 30 minutes
print timespan(10s); -- 10 seconds
print timespan(0.1s); -- 0.1 second
print timespan(100ms); -- 100 millisecond
print timespan(10microsecond); -- 10 microseconds
print timespan(1tick);
print timespan(1tick); -- 100 nanoseconds
print timespan(1.5h) / timespan(30m);
print timespan('12.23:12:23') / timespan(1s);
print '-- null';
print isnull(null);
print bool(null), int(null), long(null), real(null), double(null);
print '-- decimal';
print decimal(null);
print decimal(123.345);
print decimal(1e5);
print '-- dynamic'; -- no support for mixed types and bags for now
print dynamic(null);
print dynamic(1);
Expand Down Expand Up @@ -96,13 +100,16 @@ print todatetime('abc') == null;
print '-- make_timespan()';
print v1=make_timespan(1,12), v2=make_timespan(1,12,30), v3=make_timespan(1,12,30,55.123);
print '-- totimespan()';
print totimespan(1tick);
print totimespan('0.00:01:00');
print totimespan('abc');
print totimespan('12.23:12:23') / totimespan(1s);
-- print totimespan(strcat('12.', '23', ':12:', '23')) / timespan(1s); -> 1120343
print '-- tolong()';
print tolong('123');
print tolong('abc');
print '-- todecimal()';
print todecimal(123.345);
print todecimal(null);
-- TODO:
-- print totimespan('abc') == null;

print todecimal('abc');
-- print todecimal(4 * 2 + 3); -> 11
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
-- format_timespan()
02:03:04.1234500
29.09:00:05:12
029.09:00:05 [1234500]
-- ago()
-- datetime_diff()
17 2 13 4 29 2 5 10
Expand Down
2 changes: 1 addition & 1 deletion tests/queries/0_stateless/02366_kql_func_datetime.sql
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ print v1=format_datetime(datetime(2017-01-29 09:00:05),'yy-MM-dd [HH:mm:ss]'), v
print '-- format_timespan()';
print format_timespan(time('14.02:03:04.12345'), 'h:m:s.fffffff');
print v1=format_timespan(time('29.09:00:05.12345'), 'dd.hh:mm:ss:FF');
print v2=format_timespan(time('29.09:00:05.12345'), 'ddd.h:mm:ss [fffffff]');
-- print v2=format_timespan(time('29.09:00:05.12345'), 'ddd.h:mm:ss [fffffff]'); == '029.9:00:05 [1234500]'
print '-- ago()';
-- print ago(1d) - now();
print '-- datetime_diff()';
Expand Down
4 changes: 3 additions & 1 deletion tests/queries/0_stateless/02366_kql_func_scalar.reference
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
1970-05-11 00:00:00.000000000
336:0:0
1970-05-11 13:45:07.345000000
1970-05-11 13:45:07.345620000
1970-05-11 13:45:07.345623000
2022-09-26 10:13:23.987232000
1970-05-11 13:45:07.456336000
7 changes: 6 additions & 1 deletion tests/queries/0_stateless/02366_kql_func_scalar.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ print bin(4.5, 1);
print bin(datetime(1970-05-11 13:45:07), 1d);
print bin(16d, 7d);
print bin(datetime(1970-05-11 13:45:07.345623), 1ms);
print bin(datetime(1970-05-11 13:45:07.345623), 6microsecond);
-- print bin(datetime(2022-09-26 10:13:23.987234), 6ms); -> 2022-09-26 10:13:23.982000000
print bin(datetime(1970-05-11 13:45:07.345623), 1microsecond);
print bin(datetime(2022-09-26 10:13:23.987234), 6microseconds);
print bin(datetime(1970-05-11 13:45:07.456345672), 16microseconds);
-- print bin(datetime(2022-09-26 10:13:23.987234128), 1tick); -> 2022-09-26 10:13:23.987234100
-- print bin(datetime(2022-09-26 10:13:23.987234128), 99nanosecond); -> null
1 change: 0 additions & 1 deletion tests/queries/0_stateless/02366_kql_func_string.reference
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ PINEAPPLE
-1
-- base64_encode_fromguid()
YWUzMTMzZjItNmUyMi00OWFlLWIwNmEtMTZlNmE5YjIxMmVi
\N
-- base64_decode_toarray()
[75,117,115,116,111]
-- base64_decode_toguid()
Expand Down
6 changes: 3 additions & 3 deletions tests/queries/0_stateless/02366_kql_func_string.sql
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,12 @@ Customers | project indexof('abcdefg','cde') | take 1;
Customers | project indexof('abcdefg','cde',2) | take 1;
Customers | project indexof('abcdefg','cde',6) | take 1;
print '-- base64_encode_fromguid()';
print base64_encode_fromguid('ae3133f2-6e22-49ae-b06a-16e6a9b212eb');
print base64_encode_fromguid("abcd1231");
print base64_encode_fromguid(guid('ae3133f2-6e22-49ae-b06a-16e6a9b212eb'));
-- print base64_encode_fromguid("abcd1231"); exception is expected
print '-- base64_decode_toarray()';
print base64_decode_toarray('S3VzdG8=');
print '-- base64_decode_toguid()';
print base64_decode_toguid(base64_encode_fromguid('ae3133f2-6e22-49ae-b06a-16e6a9b212eb')) == 'ae3133f2-6e22-49ae-b06a-16e6a9b212eb';
print base64_decode_toguid(base64_encode_fromguid(guid('ae3133f2-6e22-49ae-b06a-16e6a9b212eb'))) == guid('ae3133f2-6e22-49ae-b06a-16e6a9b212eb');
print '-- parse_url()';
print parse_url('scheme://username:password@host:1234/this/is/a/path?k1=v1&k2=v2#fragment');
print '-- parse_urlquery()';
Expand Down

0 comments on commit 8a9a475

Please sign in to comment.