Added functional tests for string and array

This commit is contained in:
Larry Luo 2022-10-06 19:38:18 -07:00 committed by Yong Wang
parent 8a783cecd7
commit 94743eb641
9 changed files with 24 additions and 2 deletions

View File

@ -34,6 +34,7 @@ inf
6e-9
6e-7
172800
259200
-- guid
\N
-- timespan (time)

View File

@ -39,6 +39,7 @@ print time(-1d);
print time(6nanoseconds);
print time(6tick);
print time(2);
print time(2) + 1d;
print '-- guid'
print guid(74be27de-1e4e-49d9-b579-fe0b331d3642);
print guid(null);

View File

@ -40,6 +40,8 @@
2018-12-31 23:59:59.999999000
-- unixtime_seconds_todatetime()
2019-01-01 00:00:00.000000000
1970-01-02 00:00:00.000000000
1969-12-31 00:00:00.000000000
-- unixtime_microseconds_todatetime
2019-01-01 00:00:00.000000
-- unixtime_milliseconds_todatetime()

View File

@ -42,6 +42,8 @@ print endofyear(datetime(2017-01-01 10:10:17), -1);
print endofyear(datetime(2017-01-01 10:10:17), 1);
print '-- unixtime_seconds_todatetime()';
print unixtime_seconds_todatetime(1546300800);
print unixtime_seconds_todatetime(1d);
print unixtime_seconds_todatetime(-1d);
print '-- unixtime_microseconds_todatetime';
print unixtime_microseconds_todatetime(1546300800000000);
print '-- unixtime_milliseconds_todatetime()';

View File

@ -1,3 +1,5 @@
-- constant index value
1 c ['A',NULL,'C']
-- array_length()
1
1
@ -107,6 +109,7 @@ nan
[86400,86400,86400]
[true,true,true]
[NULL]
[NULL]
-- set_difference()
[]
[]

View File

@ -1,4 +1,12 @@
DROP TABLE IF EXISTS array_test;
CREATE TABLE array_test (floats Array(Float64),
strings Array(String),
nullable_strings Array(Nullable(String))
) ENGINE=Memory;
INSERT INTO array_test VALUES([1.0, 2.5], ['a', 'c'], ['A', NULL, 'C']);
set dialect = 'kusto';
print '-- constant index value';
array_test | project floats[0], strings[1], nullable_strings;
print '-- array_length()';
print array_length(dynamic(['John', 'Denver', 'Bob', 'Marley'])) == 4;
print array_length(dynamic([1, 2, 3])) == 3;
@ -109,6 +117,7 @@ print repeat("asd", 3);
print repeat(timespan(1d), 3);
print repeat(true, 3);
print repeat(1, -3);
print repeat(6.7,-4);
print '-- set_difference()';
print set_difference(dynamic([]), dynamic([]));
print set_difference(dynamic([]), dynamic([9]));
@ -149,4 +158,4 @@ print zip(dynamic([]), dynamic([]));
print zip(dynamic([1,3,5]), dynamic([2,4,6]));
print zip(dynamic(['Darth','Master']), dynamic(['Vader','Yoda']), dynamic(['has a suit','doesn\'t have a suit']));
print zip(dynamic([1,2,3]), dynamic([10,20]));
print zip(dynamic([]), dynamic([1,2,3]));
print zip(dynamic([]), dynamic([1,2,3]));

View File

@ -285,6 +285,8 @@ YWUzMTMzZjItNmUyMi00OWFlLWIwNmEtMTZlNmE5YjIxMmVi
{"Query Parameters":{"k1":"v1","k2":"v2","k3":"v3"}}
-- strcmp()
0 1 -1 1
-- substring()
CD
-- translate()
kusto xxx
-- trim()

View File

@ -205,7 +205,6 @@ print extract_json('$.phoneNumbers[0].type', '');
print extractjson('$.firstName', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}');
print extract_json('$.phoneNumbers[0].type', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}', typeof(string));
print extract_json('$.phoneNumbers[0].type', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}', typeof(int));
-- print extract_json('$.phoneNumbers[:1].type', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}'); -> iPhone
print extract_json('$.age', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}');
print extract_json('$.age', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}', typeof(int));
print extract_json('$.age', '{"firstName":"John","lastName":"doe","age":26,"address":{"streetAddress":"naist street","city":"Nara","postalCode":"630-0192"},"phoneNumbers":[{"type":"iPhone","number":"0123-4567-8888"},{"type":"home","number":"0123-4567-8910"}]}', typeof(long));
@ -242,6 +241,8 @@ print '-- parse_urlquery()';
print parse_urlquery('k1=v1&k2=v2&k3=v3');
print '-- strcmp()';
print strcmp('ABC','ABC'), strcmp('abc','ABC'), strcmp('ABC','abc'), strcmp('abcde','abc');
print '-- substring()';
print substring("ABCD", -2, 2);
print '-- translate()';
print translate('krasp', 'otsku', 'spark'), translate('abc', '', 'ab'), translate('abc', 'x', 'abc');
print '-- trim()';

View File

@ -54,6 +54,7 @@ Customers | summarize dcount(Education);
Customers | summarize dcountif(Education, Occupation=='Professional');
Customers | summarize count_ = count() by bin(Age, 10) | order by count_ asc;
Customers | summarize job_count = count() by Occupation | where job_count > 0;
Customers | summarize 'Edu Count'=count() by Education | sort by 'Edu Count' desc; -- { clientError 62 }
print '-- make_list() --';
Customers | summarize f_list = make_list(Education) by Occupation;