forked from Azure/usql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Saveen Reddy
committed
Jul 3, 2017
1 parent
867bda7
commit 2b56b13
Showing
5 changed files
with
150 additions
and
85 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
108 changes: 108 additions & 0 deletions
108
Training/Extending_USQL/MVA_MarkDownOutputter/MarkdownOutputter/Maps.usql
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,108 @@ | ||
/* | ||
@querylog = | ||
SELECT * FROM ( VALUES | ||
("Banana" , 300, "Image" ), | ||
("Cherry" , 300, "Image" ), | ||
("Durian" , 500, "Image" ), | ||
("Apple" , 100, "Web" ), | ||
("Fig" , 200, "Web" ), | ||
("Papaya" , 200, "Web" ), | ||
("Avocado" , 300, "Web" ), | ||
("Cherry" , 400, "Web" ), | ||
("Durian" , 500, "Web" ) ) | ||
AS T(Query,Latency,Vertical); | ||
|
||
@employees = | ||
SELECT * FROM ( VALUES | ||
(1, "Noah", "Engineering", 100, 10000), | ||
(2, "Sophia", "Engineering", 100, 20000), | ||
(3, "Liam", "Engineering", 100, 30000), | ||
(4, "Emma", "HR", 200, 10000), | ||
(5, "Jacob", "HR", 200, 10000), | ||
(6, "Olivia", "HR", 200, 10000), | ||
(7, "Mason", "Executive", 300, 50000), | ||
(8, "Ava", "Marketing", 400, 15000), | ||
(9, "Ethan", "Marketing", 400, 10000) ) | ||
AS T(EmpID, EmpName, DeptName, DeptID, Salary); | ||
|
||
@result= | ||
SELECT | ||
EmpName, | ||
DeptName, | ||
SUM(Salary) OVER( PARTITION BY DeptName ) AS SalaryByDept | ||
FROM @employees; | ||
|
||
|
||
OUTPUT @result | ||
TO "/result.md" | ||
USING new MVADemo.MarkdownOutputter(); | ||
|
||
OUTPUT @querylog | ||
TO "/querylog.md" | ||
USING new MVADemo.MarkdownOutputter(); | ||
*/ | ||
|
||
REFERENCE ASSEMBLY [master].[DocumentOutputers]; | ||
|
||
|
||
@cities = | ||
SELECT * FROM | ||
( VALUES | ||
( "Vermont", "Burlington;Essex;South Burlington;Colchester;Rutland" ), | ||
( "Virginia", "Virginia Beach;Norfolk;Chesapeake;Richmond;Newport News" ), | ||
( "Washington", "Seattle;Spokane;Tacoma;Vancouver;Bellevue" ), | ||
( "West Virginia", "Charleston;Huntington;Parkersburg;Morgantown;Wheeling" ), | ||
( "Wisconsin", "Milwaukee;Madison;Green Bay;Kenosha;Racine" ), | ||
( "Wyoming", "Cheyenne;Casper;Laramie;Gillette;Rock Springs" ) | ||
) | ||
AS T(State, Cities); | ||
|
||
@xxx = | ||
SELECT * | ||
FROM | ||
( VALUES | ||
( "Website", new SqlMap<string,string> { | ||
{"Mallory", "PM"}, | ||
{"Bob", "Dev"} , | ||
{"Alice", "Dev"} , | ||
{"Stan", "Dev"} , | ||
{"Chris", "UX"} , | ||
} | ||
), | ||
( "DB", new SqlMap<string,string> { | ||
{"Ted", "Test"}, | ||
{"Joe", "Dev"} , | ||
{"Chuck", "Dev"} | ||
} | ||
) | ||
) | ||
AS T(Category, Dict); | ||
|
||
|
||
@output = | ||
SELECT | ||
State, | ||
SqlArray.Create( Cities.Split(';') ) AS Cities | ||
FROM @cities; | ||
|
||
@output = | ||
SELECT | ||
State , | ||
SqlArray.Create( Cities.Where( c=>c.StartsWith("C") ) ) AS Cities | ||
FROM @output; | ||
|
||
@output = | ||
SELECT | ||
State , | ||
Cities , | ||
Cities.Count AS NumCities | ||
FROM @output; | ||
|
||
OUTPUT @output | ||
TO "/cities.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true, outputHeaderType: true); | ||
|
||
OUTPUT @xxx | ||
TO "/xxx.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true, outputHeaderType: true); | ||
|
1 change: 1 addition & 0 deletions
1
Training/Extending_USQL/MVA_MarkDownOutputter/MarkdownOutputter/Maps.usql.cs
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 @@ | ||
|
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
116 changes: 32 additions & 84 deletions
116
Training/Extending_USQL/MVA_MarkDownOutputter/MarkdownOutputter/WindowFunctions.usql
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,96 +1,44 @@ | ||
/* | ||
@querylog = | ||
SELECT * FROM ( VALUES | ||
("Banana" , 300, "Image" ), | ||
("Cherry" , 300, "Image" ), | ||
("Durian" , 500, "Image" ), | ||
("Apple" , 100, "Web" ), | ||
("Fig" , 200, "Web" ), | ||
("Papaya" , 200, "Web" ), | ||
("Avocado" , 300, "Web" ), | ||
("Cherry" , 400, "Web" ), | ||
("Durian" , 500, "Web" ) ) | ||
AS T(Query,Latency,Vertical); | ||
|
||
@employees = | ||
SELECT * FROM ( VALUES | ||
(1, "Noah", "Engineering", 100, 10000), | ||
(2, "Sophia", "Engineering", 100, 20000), | ||
(3, "Liam", "Engineering", 100, 30000), | ||
(4, "Emma", "HR", 200, 10000), | ||
(5, "Jacob", "HR", 200, 10000), | ||
(6, "Olivia", "HR", 200, 10000), | ||
(7, "Mason", "Executive", 300, 50000), | ||
(8, "Ava", "Marketing", 400, 15000), | ||
(9, "Ethan", "Marketing", 400, 10000) ) | ||
AS T(EmpID, EmpName, DeptName, DeptID, Salary); | ||
|
||
@result= | ||
SELECT | ||
EmpName, | ||
DeptName, | ||
SUM(Salary) OVER( PARTITION BY DeptName ) AS SalaryByDept | ||
FROM @employees; | ||
|
||
|
||
OUTPUT @result | ||
TO "/result.md" | ||
USING new MVADemo.MarkdownOutputter(); | ||
|
||
OUTPUT @querylog | ||
TO "/querylog.md" | ||
USING new MVADemo.MarkdownOutputter(); | ||
*/ | ||
|
||
| ||
REFERENCE ASSEMBLY [master].[DocumentOutputers]; | ||
|
||
|
||
@cities = | ||
SELECT * FROM | ||
@projectmembers = | ||
SELECT * | ||
FROM | ||
( VALUES | ||
( "Vermont", "Burlington;Essex;South Burlington;Colchester;Rutland" ), | ||
( "Virginia", "Virginia Beach;Norfolk;Chesapeake;Richmond;Newport News" ), | ||
( "Washington", "Seattle;Spokane;Tacoma;Vancouver;Bellevue" ), | ||
( "West Virginia", "Charleston;Huntington;Parkersburg;Morgantown;Wheeling" ), | ||
( "Wisconsin", "Milwaukee;Madison;Green Bay;Kenosha;Racine" ), | ||
( "Wyoming", "Cheyenne;Casper;Laramie;Gillette;Rock Springs" ) | ||
) | ||
AS T(State, Cities); | ||
|
||
@xxx = | ||
SELECT * | ||
FROM | ||
( VALUES | ||
( "cat1", new SqlMap<string,string> { {"A", "X"}, {"B", "Y"} } ) | ||
|
||
( "Website", new SqlMap<string,string> { | ||
{"Mallory", "PM"}, | ||
{"Bob", "Dev"} , | ||
{"Alice", "Dev"} , | ||
{"Stan", "Dev"} , | ||
{"Chris", "UX"} , | ||
} | ||
), | ||
( "DB", new SqlMap<string,string> { | ||
{"Ted", "Test"}, | ||
{"Joe", "Dev"} , | ||
{"Chuck", "Dev"} | ||
} | ||
) | ||
) | ||
AS T(Category, Dict); | ||
AS T(Project, Members); | ||
|
||
|
||
OUTPUT @projectmembers | ||
TO "/projectmembers.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true ); | ||
|
||
@output = | ||
SELECT | ||
State, | ||
SqlArray.Create( Cities.Split(';') ) AS Cities | ||
FROM @cities; | ||
|
||
@output = | ||
SELECT | ||
State , | ||
SqlArray.Create( Cities.Where( c=>c.StartsWith("C") ) ) AS Cities | ||
FROM @output; | ||
SELECT | ||
Project, | ||
Members.ContainsKey("Mallory") AS ContainsMallory | ||
FROM @projectmembers; | ||
|
||
OUTPUT @output | ||
TO "/output.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true ); | ||
|
||
@output = | ||
SELECT | ||
State , | ||
Cities , | ||
Cities.Count AS NumCities | ||
FROM @output; | ||
|
||
OUTPUT @output | ||
TO "/cities.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true, outputHeaderType: true); | ||
|
||
OUTPUT @xxx | ||
TO "/xxx.md" | ||
USING new DocumentOutputers.MarkdownOutputer(outputHeader: true, outputHeaderType: true); | ||
|
||
|