A massive group by test with real data.

pull/333/head
Todd Persen 2014-03-11 18:05:04 -04:00
parent fe10d5b1b0
commit c54588dd43
1 changed files with 185 additions and 0 deletions

View File

@ -318,6 +318,191 @@ func (self *ServerSuite) TestCountQueryOnSingleShard(c *C) {
c.Assert(series.GetValueForPointAndColumn(1, "count", c).(float64), Equals, float64(1))
}
func (self *ServerSuite) TestRealGroupBy(c *C) {
data := `[{
"name": "sku_orders_hto_306-87",
"columns": ["time", "order_id", "order_product_id"],
"points": [
[1394308403000, 25798, 90727],
[1394096471000, 25619, 89815],
[1394023654000, 25558, 89552],
[1394017974000, 25545, 89487],
[1394017169000, 25542, 89478],
[1393961559000, 25510, 89321],
[1393758667000, 25330, 88488],
[1393662424000, 25250, 88131],
[1393660284000, 25249, 88123],
[1393316427000, 24859, 86603],
[1392995009000, 24559, 85177],
[1392837085000, 24375, 84268],
[1392703645000, 24179, 83451],
[1392636655000, 24109, 83091],
[1392462519000, 23917, 82141],
[1392401809000, 23879, 81962],
[1392304093000, 23747, 81296],
[1392289143000, 23711, 81130],
[1392275989000, 23681, 80966],
[1392207218000, 23606, 80615],
[1392105143000, 23492, 80079],
[1391707758000, 23194, 78680],
[1391681584000, 23145, 78430],
[1391678674000, 23139, 78397],
[1391638809000, 23112, 83088],
[1391627599000, 23092, 78178],
[1391547699000, 22999, 77679],
[1391460586000, 22922, 77317],
[1391416547000, 22853, 76974],
[1391353157000, 22814, 76789],
[1391343724000, 22804, 76737],
[1391283742000, 22766, 76543],
[1391181812000, 22653, 75973],
[1391072131000, 22459, 75032],
[1391060670000, 22437, 74936],
[1391018843000, 22399, 74754],
[1390988436000, 22327, 74374],
[1390940319000, 22283, 74160],
[1390891751000, 22119, 73365],
[1390890564000, 22112, 73323],
[1390890297000, 22107, 78521],
[1390890117000, 22104, 73291],
[1390888081000, 22096, 73252],
[1390887772000, 22095, 73249]
]
}]`
self.serverProcesses[0].Post("/db/test_rep/series?u=paul&p=pass", data, c)
data = `[{
"name": "sku_orders_hto_306-67",
"columns": ["time", "order_id", "order_product_id"],
"points": [
[1394127830000, 25656, 89996],
[1394096295000, 25617, 89804],
[1394033181000, 25576, 89621],
[1394017169000, 25542, 89477],
[1393946314000, 25492, 89255],
[1393934255000, 25471, 89158],
[1393920481000, 25454, 89074],
[1393918574000, 25449, 89059],
[1393892147000, 25443, 89040],
[1393883034000, 25437, 89007],
[1393872507000, 25429, 88956],
[1393856915000, 25412, 88874],
[1393849643000, 25400, 88800],
[1393773937000, 25343, 88540],
[1393758667000, 25330, 88487],
[1393662424000, 25250, 88129],
[1393597853000, 25203, 87962],
[1393569612000, 25151, 87771],
[1393533783000, 25134, 87691],
[1393413072000, 24969, 87119],
[1393358360000, 24923, 86874],
[1393341285000, 24899, 86775],
[1393316427000, 24859, 86604],
[1393236191000, 24778, 86286],
[1393189696000, 24754, 86151],
[1393178560000, 24741, 86065],
[1393146070000, 24702, 85900],
[1393136028000, 24686, 85816],
[1393112374000, 24681, 85785],
[1393099370000, 24668, 85716],
[1393096719000, 24665, 85702],
[1393088205000, 24656, 85665],
[1393007664000, 24577, 85270],
[1392974360000, 24531, 85070],
[1392929913000, 24490, 84799],
[1392929102000, 24489, 84786],
[1392883165000, 24405, 84399],
[1392793278000, 24294, 83936],
[1392753876000, 24278, 83862],
[1392720329000, 24214, 83603],
[1392714746000, 24203, 83555],
[1392708003000, 24186, 83479],
[1392703645000, 24179, 83448],
[1392701245000, 24176, 83431],
[1392658814000, 24150, 83301],
[1392652348000, 24134, 83212],
[1392642305000, 24120, 83164],
[1392636655000, 24109, 83090],
[1392633742000, 24102, 83055],
[1392566655000, 24021, 82670],
[1392560788000, 24013, 82633],
[1392540563000, 23994, 82533],
[1392498475000, 23962, 82378],
[1392479295000, 23944, 82304],
[1392476505000, 23941, 82293],
[1392413768000, 23891, 82014],
[1392383113000, 23847, 81794],
[1392374154000, 23827, 81703],
[1392363800000, 23805, 81556],
[1392275989000, 23681, 80967],
[1392208228000, 23607, 80617],
[1392150829000, 23564, 80442],
[1392105143000, 23492, 80078],
[1392060844000, 23468, 79971],
[1391986799000, 23412, 79711],
[1391974922000, 23403, 79644],
[1391965155000, 23397, 79623],
[1391940963000, 23369, 79497],
[1391847849000, 23297, 79164],
[1391784730000, 23265, 79033],
[1391776948000, 23252, 78977],
[1391767550000, 23235, 78895],
[1391707758000, 23194, 78682],
[1391693189000, 23161, 78516],
[1391691391000, 23157, 78497],
[1391681584000, 23145, 78429],
[1391633408000, 23105, 78239],
[1391627599000, 23092, 78177],
[1391605518000, 23060, 78026],
[1391601531000, 23046, 77942],
[1391578346000, 23019, 77785],
[1391518604000, 22971, 77543],
[1391515497000, 22967, 77527],
[1391446215000, 22904, 77220],
[1391420126000, 22861, 77028],
[1391416547000, 22853, 76971],
[1391387621000, 22834, 76883],
[1391367769000, 22823, 76839],
[1391342864000, 22803, 76732],
[1391175187000, 22632, 75884],
[1391162331000, 22606, 75749],
[1391143666000, 22570, 75556],
[1391116400000, 22556, 75468],
[1391070045000, 22456, 75021],
[1391030959000, 22422, 74847],
[1390990512000, 22336, 74423],
[1390978045000, 22309, 74297],
[1390938734000, 22279, 77476],
[1390938108000, 22276, 74125],
[1390936641000, 22272, 74103],
[1390923498000, 22241, 73999],
[1390922359000, 22239, 73933],
[1390915811000, 22217, 73837],
[1390901530000, 22161, 73561],
[1390899150000, 22153, 73527],
[1390894824000, 22133, 73437],
[1390891700000, 22118, 73354],
[1390890564000, 22112, 73322],
[1390890117000, 22104, 73290],
[1390860722000, 22076, 77906],
[1390843479000, 22039, 72988]
]
}]`
self.serverProcesses[0].Post("/db/test_rep/series?u=paul&p=pass", data, c)
collection := self.serverProcesses[0].Query("test_rep", "select count(order_id) from sku_orders_hto_306-67 group by time(168h);", false, c)
c.Assert(collection.Members, HasLen, 1)
series := collection.GetSeries("sku_orders_hto_306-67", c)
c.Assert(series.Points, HasLen, 7)
c.Assert(series.GetValueForPointAndColumn(0, "count", c).(float64), Equals, float64(2))
c.Assert(series.GetValueForPointAndColumn(1, "count", c).(float64), Equals, float64(17))
c.Assert(series.GetValueForPointAndColumn(2, "count", c).(float64), Equals, float64(18))
c.Assert(series.GetValueForPointAndColumn(3, "count", c).(float64), Equals, float64(23))
c.Assert(series.GetValueForPointAndColumn(4, "count", c).(float64), Equals, float64(16))
c.Assert(series.GetValueForPointAndColumn(5, "count", c).(float64), Equals, float64(18))
c.Assert(series.GetValueForPointAndColumn(6, "count", c).(float64), Equals, float64(17))
}
func (self *ServerSuite) TestGroupByDay(c *C) {
data := `[{"points": [[4], [10], [5]], "name": "test_group_by_day", "columns": ["value"]}]`
self.serverProcesses[0].Post("/db/test_rep/series?u=paul&p=pass", data, c)