ClickHouse/tests/queries/0_stateless/02366_kql_tabular.sql

89 lines
4.4 KiB
MySQL
Raw Normal View History

DROP TABLE IF EXISTS Customers;
CREATE TABLE Customers
(
FirstName Nullable(String),
LastName String,
Occupation String,
Education String,
Age Nullable(UInt8)
) ENGINE = Memory;
INSERT INTO Customers VALUES ('Theodore','Diaz','Skilled Manual','Bachelors',28), ('Stephanie','Cox','Management','Bachelors',33), ('Peter','Nara','Skilled Manual','Graduate Degree',26), ('Latoya','Shen','Professional','Graduate Degree',25), ('Joshua','Lee','Professional','Partial College',26), ('Edward','Hernandez','Skilled Manual','High School',36), ('Dalton','Wood','Professional','Partial College',42), ('Christine','Nara','Skilled Manual','Partial College',33), ('Cameron','Rodriguez','Professional','Partial College',28), ('Angel','Stewart','Professional','Partial College',46);
set dialect='kusto';
2022-07-27 00:24:29 +00:00
print '-- test Query only has table name: --';
Customers;
2022-07-27 00:24:29 +00:00
print '-- Query has Column Selection --';
Customers | project FirstName,LastName,Occupation;
2022-07-27 00:24:29 +00:00
print '-- Query has limit --';
Customers | project FirstName,LastName,Occupation | take 5;
Customers | project FirstName,LastName,Occupation | limit 5;
2022-07-27 00:24:29 +00:00
print '-- Query has second limit with bigger value --';
Customers | project FirstName,LastName,Occupation | take 5 | take 7;
2022-07-27 00:24:29 +00:00
print '-- Query has second limit with smaller value --';
Customers | project FirstName,LastName,Occupation | take 5 | take 3;
2022-07-27 00:24:29 +00:00
print '-- Query has second Column selection --';
Customers | project FirstName,LastName,Occupation | take 3 | project FirstName,LastName;
2022-07-27 00:24:29 +00:00
print '-- Query has second Column selection with extra column --';
2022-09-14 06:12:14 +00:00
Customers| project FirstName,LastName,Occupation | take 3 | project FirstName,LastName,Education;-- { serverError 47 }
2022-07-27 00:24:29 +00:00
print '-- Query with desc sort --';
2022-07-20 18:18:03 +00:00
Customers | project FirstName | take 5 | sort by FirstName desc;
Customers | project Occupation | take 5 | order by Occupation desc;
2022-07-27 00:24:29 +00:00
print '-- Query with asc sort --';
2022-07-20 18:18:03 +00:00
Customers | project Occupation | take 5 | sort by Occupation asc;
2022-07-27 00:24:29 +00:00
print '-- Query with sort (without keyword asc desc) --';
2022-07-20 18:18:03 +00:00
Customers | project FirstName | take 5 | sort by FirstName;
Customers | project Occupation | take 5 | order by Occupation;
2022-07-27 00:24:29 +00:00
print '-- Query with sort 2 Columns with different direction --';
2022-07-20 18:18:03 +00:00
Customers | project FirstName,LastName,Occupation | take 5 | sort by Occupation asc, LastName desc;
2022-07-27 00:24:29 +00:00
print '-- Query with second sort --';
2022-07-20 18:18:03 +00:00
Customers | project FirstName,LastName,Occupation | take 5 | sort by Occupation desc |sort by Occupation asc, LastName desc;
2022-07-27 00:24:29 +00:00
print '-- Test String Equals (==) --';
Customers | project FirstName,LastName,Occupation | where Occupation == 'Skilled Manual';
2022-07-27 00:24:29 +00:00
print '-- Test String Not equals (!=) --';
Customers | project FirstName,LastName,Occupation | where Occupation != 'Skilled Manual';
2022-07-27 00:24:29 +00:00
print '-- Test Filter using a list (in) --';
Customers | project FirstName,LastName,Occupation,Education | where Education in ('Bachelors','High School');
2022-07-27 00:24:29 +00:00
print '-- Test Filter using a list (!in) --';
set dialect='kusto';
Customers | project FirstName,LastName,Occupation,Education | where Education !in ('Bachelors','High School');
2022-07-27 00:24:29 +00:00
print '-- Test Filter using common string operations (contains_cs) --';
Customers | project FirstName,LastName,Occupation,Education | where Education contains_cs 'Coll';
2022-07-27 00:24:29 +00:00
print '-- Test Filter using common string operations (startswith_cs) --';
Customers | project FirstName,LastName,Occupation,Education | where Occupation startswith_cs 'Prof';
2022-07-27 00:24:29 +00:00
print '-- Test Filter using common string operations (endswith_cs) --';
Customers | project FirstName,LastName,Occupation,Education | where FirstName endswith_cs 'a';
2022-07-27 00:24:29 +00:00
print '-- Test Filter using numerical equal (==) --';
Customers | project FirstName,LastName,Occupation,Education,Age | where Age == 26;
2022-07-27 00:24:29 +00:00
print '-- Test Filter using numerical great and less (> , <) --';
Customers | project FirstName,LastName,Occupation,Education,Age | where Age > 30 and Age < 40;
2022-07-27 00:24:29 +00:00
print '-- Test Filter using multi where --';
Customers | project FirstName,LastName,Occupation,Education,Age | where Age > 30 | where Occupation == 'Professional';
2022-09-28 14:30:20 +00:00
print '-- Complex query with unknown function --';
hits | where CounterID == 62 and EventDate >= '2013-07-14' and EventDate <= '2013-07-15' and IsRefresh == 0 and DontCountHits == 0 | summarize count() by d=bin(poopoo(EventTime), 1m) | order by d | limit 10; -- { clientError UNKNOWN_FUNCTION }
2022-09-28 20:11:17 +00:00
print '-- Missing column in front of startsWith --';
StormEvents | where startswith "W" | summarize Count=count() by State; -- { clientError SYNTAX_ERROR }