Skip to content

Commit

Permalink
updated sample
Browse files Browse the repository at this point in the history
  • Loading branch information
Saveen Reddy committed Jul 3, 2017
1 parent 867bda7 commit 2b56b13
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public override void Output(USQLINTERFACES.IRow row, USQLINTERFACES.IUnstructure
val = row.Get<string>(col.Name).ToString();
val = val ?? "NULL";
}
else if (coltype == typeof(bool))
{
val = row.Get<bool>(col.Name).ToString();
}
else if (coltype == typeof(char))
{
val = row.Get<char>(col.Name).ToString();
Expand Down Expand Up @@ -151,7 +155,7 @@ public override void Output(USQLINTERFACES.IRow row, USQLINTERFACES.IUnstructure
catch (System.NullReferenceException)
{
// Handling NULL values--keeping them empty
val = "EXCEPTION";
val = "NullReferenceException";
}
streamWriter.Write(" ");
streamWriter.Write(val);
Expand Down
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);

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
<OutputPath>bin\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Script Include="Maps.usql" />
<Script Include="Joins.usql" />
<Script Include="WindowFunctions.usql" />
<ScriptCode Include="Maps.usql.cs">
<DependentUpon>Maps.usql</DependentUpon>
</ScriptCode>
<ScriptCode Include="Joins.usql.cs">
<DependentUpon>Joins.usql</DependentUpon>
</ScriptCode>
Expand Down
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);


0 comments on commit 2b56b13

Please sign in to comment.