Added more samples
This commit is contained in:
Родитель
f223f97e9f
Коммит
f65e0f0bde
|
@ -0,0 +1,41 @@
|
|||
DECLARE @StartDate = DateTime.Parse("1979-03-31");
|
||||
|
||||
@numbers_10 =
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(VALUES
|
||||
(0),
|
||||
(1),
|
||||
(2),
|
||||
(3),
|
||||
(4),
|
||||
(5),
|
||||
(6),
|
||||
(7),
|
||||
(8),
|
||||
(9)
|
||||
) AS T(Value);
|
||||
|
||||
@numbers_100 =
|
||||
SELECT (a.Value*10 + b.Value) AS Value
|
||||
FROM @numbers_10 AS a CROSS JOIN @numbers_10 AS b;
|
||||
|
||||
@numbers_10000 =
|
||||
SELECT (a.Value*100 + b.Value) AS Value
|
||||
FROM @numbers_100 AS a CROSS JOIN @numbers_100 AS b;
|
||||
|
||||
@dates_10000 =
|
||||
SELECT
|
||||
Value,
|
||||
@StartDate.AddDays( Value ) AS Date
|
||||
FROM @numbers_10000;
|
||||
|
||||
OUTPUT @numbers_10000
|
||||
TO "/Samples/Output/numbers_10000.csv"
|
||||
USING Outputters.Csv(outputHeader:true);
|
||||
|
||||
OUTPUT @dates_10000
|
||||
TO "/Samples/Output/dates_10000.csv"
|
||||
USING Outputters.Csv(outputHeader:true);
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
@projectmembers =
|
||||
SELECT *
|
||||
FROM
|
||||
( VALUES
|
||||
( "Website","Mallory", "PM" ),
|
||||
( "Website","Bob", "Dev" ),
|
||||
( "Website","Alice", "Dev" ) ,
|
||||
( "Website","Stan", "Dev" ) ,
|
||||
( "Website","Chris", "UX" ) ,
|
||||
( "DB", "Ted", "Test" ),
|
||||
( "DB", "Joe", "Dev" ) ,
|
||||
( "DB", "Chuck", "Dev" )
|
||||
)
|
||||
AS T(Project, Employee, Role);
|
||||
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS MyDB;
|
||||
|
||||
DROP TABLE IF EXISTS MyDB.dbo.ProjectMembersRaw;
|
||||
|
||||
CREATE TABLE MyDB.dbo.ProjectMembersRaw
|
||||
(
|
||||
INDEX idx
|
||||
CLUSTERED(Project ASC)
|
||||
DISTRIBUTED BY
|
||||
RANGE(Project)
|
||||
) AS SELECT * FROM @projectmembers;
|
|
@ -0,0 +1,30 @@
|
|||
@projectmembers_raw =
|
||||
SELECT *
|
||||
FROM
|
||||
( VALUES
|
||||
( "Website","Mallory", "PM" ),
|
||||
( "Website","Bob", "Dev" ),
|
||||
( "Website","Alice", "Dev" ) ,
|
||||
( "Website","Stan", "Dev" ) ,
|
||||
( "Website","Chris", "UX" ) ,
|
||||
( "DB", "Ted", "Test" ),
|
||||
( "DB", "Joe", "Dev" ) ,
|
||||
( "DB", "Chuck", "Dev" )
|
||||
)
|
||||
AS T(Project, Employee, Role);
|
||||
|
||||
@projectmembers =
|
||||
SELECT
|
||||
Project,
|
||||
MAP_AGG<string, string>(Employee, Role) AS Members
|
||||
FROM @projectmembers_raw
|
||||
GROUP BY Project;
|
||||
|
||||
@projectmembers =
|
||||
SELECT Project,
|
||||
string.Join(",", Members.Select(p => String.Format("{0}:{1}", p.Key, p.Value))) AS Members
|
||||
FROM @projectmembers;
|
||||
|
||||
OUTPUT @projectmembers
|
||||
TO @"/Samples/Output/MAP_AGG_output.tsv"
|
||||
USING Outputters.Tsv();
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
@num_per_group = 3;
|
||||
|
||||
@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);
|
||||
|
||||
@result =
|
||||
SELECT
|
||||
*,
|
||||
ROW_NUMBER()
|
||||
OVER (PARTITION BY Vertical ORDER BY 1) AS RowNumber
|
||||
FROM @querylog;
|
||||
|
||||
@result =
|
||||
SELECT *
|
||||
FROM @result
|
||||
WHERE RowNumber <= @num_per_group;
|
|
@ -0,0 +1,30 @@
|
|||
@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);
|
||||
|
||||
@result =
|
||||
SELECT
|
||||
Vertical,
|
||||
Query,
|
||||
PERCENTILE_CONT(0.5)
|
||||
WITHIN GROUP (ORDER BY Latency)
|
||||
OVER ( PARTITION BY Vertical ) AS PercentileCont50,
|
||||
PERCENTILE_DISC(0.5)
|
||||
WITHIN GROUP (ORDER BY Latency)
|
||||
OVER ( PARTITION BY Vertical ) AS PercentileDisc50
|
||||
FROM @querylog;
|
||||
|
||||
|
||||
OUTPUT @result
|
||||
TO @"/Samples/Output/percentile.tsv"
|
||||
USING Outputters.Tsv();
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
@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);
|
||||
|
||||
@result =
|
||||
SELECT
|
||||
*,
|
||||
ROW_NUMBER() OVER (PARTITION BY Vertical ORDER BY Latency) AS RowNumber,
|
||||
RANK() OVER (PARTITION BY Vertical ORDER BY Latency) AS Rank,
|
||||
DENSE_RANK() OVER (PARTITION BY Vertical ORDER BY Latency) AS DenseRank
|
||||
FROM @querylog;
|
||||
|
||||
|
||||
OUTPUT @result
|
||||
TO @"/Samples/Output/ranking.tsv"
|
||||
USING Outputters.Tsv();
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
@num_per_group = 3;
|
||||
|
||||
@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);
|
||||
|
||||
@result =
|
||||
SELECT
|
||||
*,
|
||||
ROW_NUMBER()
|
||||
OVER (PARTITION BY Vertical ORDER BY Latency) AS RowNumber
|
||||
FROM @querylog;
|
||||
|
||||
@result =
|
||||
SELECT *
|
||||
FROM @result
|
||||
WHERE RowNumber <= @num_per_group;
|
Загрузка…
Ссылка в новой задаче