forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement functional tests for KQL functions
(cherry picked from commit 46ee780)
- Loading branch information
Showing
7 changed files
with
182 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- extend #1 -- | ||
Aldi Apple 4 2016-09-10 400 | ||
Costco Apple 2 2016-09-11 200 | ||
-- extend #2 -- | ||
Apple 200 | ||
Apple 400 | ||
-- extend #3 -- | ||
Apple cost 480 on average based on 5 samples. | ||
Snargaluff cost 28080 on average based on 5 samples. | ||
-- extend #4 -- | ||
1 | ||
-- extend #5 -- | ||
Aldi Apple 4 2016-09-10 Apple was purchased from Aldi for $4 on 2016-09-10 400 | ||
Costco Apple 2 2016-09-11 Apple was purchased from Costco for $2 on 2016-09-11 200 | ||
-- extend #6 -- | ||
-- extend #7 -- | ||
-- extend #8 -- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-- datatable(Supplier:string, Fruit:string, Price: real, Purchase:datetime) | ||
-- [ | ||
-- 'Aldi','Apple',4,'2016-09-10', | ||
-- 'Costco','Apple',2,'2016-09-11', | ||
-- 'Aldi','Apple',6,'2016-09-10', | ||
-- 'Costco','Snargaluff',100,'2016-09-12', | ||
-- 'Aldi','Apple',7,'2016-09-12', | ||
-- 'Aldi','Snargaluff',400,'2016-09-11', | ||
-- 'Costco','Snargaluff',104,'2016-09-12', | ||
-- 'Aldi','Apple',5,'2016-09-12', | ||
-- 'Aldi','Snargaluff',600,'2016-09-11', | ||
-- 'Costco','Snargaluff',200,'2016-09-10', | ||
-- ] | ||
|
||
DROP TABLE IF EXISTS Ledger; | ||
CREATE TABLE Ledger | ||
( | ||
Supplier Nullable(String), | ||
Fruit String , | ||
Price Float64, | ||
Purchase Date | ||
) ENGINE = Memory; | ||
INSERT INTO Ledger VALUES ('Aldi','Apple',4,'2016-09-10'), ('Costco','Apple',2,'2016-09-11'), ('Aldi','Apple',6,'2016-09-10'), ('Costco','Snargaluff',100,'2016-09-12'), ('Aldi','Apple',7,'2016-09-12'), ('Aldi','Snargaluff',400,'2016-09-11'),('Costco','Snargaluff',104,'2016-09-12'),('Aldi','Apple',5,'2016-09-12'),('Aldi','Snargaluff',600,'2016-09-11'),('Costco','Snargaluff',200,'2016-09-10'); | ||
|
||
set dialect = 'kusto'; | ||
|
||
print '-- extend #1 --'; | ||
Ledger | extend PriceInCents = 100 * Price | take 2; | ||
|
||
print '-- extend #2 --'; | ||
Ledger | extend PriceInCents = 100 * Price | sort by PriceInCents asc | project Fruit, PriceInCents | take 2; | ||
|
||
print '-- extend #3 --'; | ||
Ledger | extend PriceInCents = 100 * Price | sort by PriceInCents asc | project Fruit, PriceInCents | summarize AveragePrice = avg(PriceInCents), Purchases = count() by Fruit | extend Sentence = strcat(Fruit, ' cost ', tostring(AveragePrice), ' on average based on ', tostring(Purchases), ' samples.') | project Sentence; | ||
|
||
print '-- extend #4 --'; | ||
Ledger | extend a = Price | extend b = a | extend c = a, d = b + 500 | extend Pass = bool(b == a and c == a and d == b + 500) | summarize binary_all_and(Pass); | ||
|
||
print '-- extend #5 --'; | ||
Ledger | take 2 | extend strcat(Fruit, ' was purchased from ', Supplier, ' for $', tostring(Price), ' on ', tostring(Purchase)) | extend PriceInCents = 100 * Price; | ||
|
||
print '-- extend #6 --'; | ||
-- Ledger | extend Price = 100 * Price | ||
|
||
print '-- extend #7 --'; | ||
-- print a = 4 | extend a = 5 | ||
|
||
print '-- extend #8 --'; | ||
-- print x = 5 | extend array_sort_desc(range(0, x), range(1, x + 1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,35 @@ | ||
DROP TABLE IF EXISTS mv_expend_test_table; | ||
CREATE TABLE mv_expend_test_table | ||
-- datatable(a: int, b: dynamic, c: dynamic, d: dynamic) [ | ||
-- 1, dynamic(['Salmon', 'Steak', 'Chicken']), dynamic([1, 2, 3, 4]), dynamic([5, 6, 7, 8]) | ||
-- ] | ||
|
||
DROP TABLE IF EXISTS mv_expand_test_table; | ||
CREATE TABLE mv_expand_test_table | ||
( | ||
a UInt8, | ||
b Array(String), | ||
c Array(Int8), | ||
d Array(Int8) | ||
) ENGINE = Memory; | ||
INSERT INTO mv_expend_test_table VALUES (1, ['Salmon', 'Steak','Chicken'],[1,2,3,4],[5,6,7,8]); | ||
INSERT INTO mv_expand_test_table VALUES (1, ['Salmon', 'Steak','Chicken'],[1,2,3,4],[5,6,7,8]); | ||
set dialect='kusto'; | ||
print '-- mv-expend'; | ||
mv_expend_test_table | mv-expand c; | ||
mv_expend_test_table | mv-expand c, d; | ||
mv_expend_test_table | mv-expand b | mv-expand c; | ||
mv_expend_test_table | mv-expand with_itemindex=index b, c, d; | ||
mv_expend_test_table | mv-expand array_concat(c,d); | ||
mv_expend_test_table | mv-expand x = c, y = d; | ||
mv_expend_test_table | mv-expand xy = array_concat(c, d); | ||
mv_expend_test_table | mv-expand xy = array_concat(c, d) limit 2| summarize count() by xy; | ||
mv_expend_test_table | mv-expand with_itemindex=index c,d to typeof(bool); | ||
-- mv_expend_test_table | mv-expand c to typeof(bool); | ||
print '-- mv-expand --'; | ||
print '-- mv_expand_test_table | mv-expand c --'; | ||
mv_expand_test_table | mv-expand c; | ||
print '-- mv_expand_test_table | mv-expand c, d --'; | ||
mv_expand_test_table | mv-expand c, d; | ||
print '-- mv_expand_test_table | mv-expand b | mv-expand c --'; | ||
mv_expand_test_table | mv-expand b | mv-expand c; | ||
print '-- mv_expand_test_table | mv-expand with_itemindex=index b, c, d --'; | ||
mv_expand_test_table | mv-expand with_itemindex=index b, c, d; | ||
print '-- mv_expand_test_table | mv-expand array_concat(c,d) --'; | ||
mv_expand_test_table | mv-expand array_concat(c,d); | ||
print '-- mv_expand_test_table | mv-expand x = c, y = d --'; | ||
mv_expand_test_table | mv-expand x = c, y = d; | ||
print '-- mv_expand_test_table | mv-expand xy = array_concat(c, d) --'; | ||
mv_expand_test_table | mv-expand xy = array_concat(c, d); | ||
print '-- mv_expand_test_table | mv-expand xy = array_concat(c, d) limit 2| summarize count() by xy --'; | ||
mv_expand_test_table | mv-expand xy = array_concat(c, d) limit 2| summarize count() by xy; | ||
print '-- mv_expand_test_table | mv-expand with_itemindex=index c,d to typeof(bool) --'; | ||
mv_expand_test_table | mv-expand with_itemindex=index c,d to typeof(bool); | ||
print '-- mv_expand_test_table | mv-expand c to typeof(bool) --'; | ||
mv_expand_test_table | mv-expand c to typeof(bool); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters