@@ -244,6 +244,56 @@ def test_query_into_dataframe(self):
244
244
for k in expected :
245
245
assert_frame_equal (expected [k ], result [k ])
246
246
247
+ def test_multiquery_into_dataframe (self ):
248
+ data = {
249
+ "results" : [
250
+ {
251
+ "series" : [
252
+ {
253
+ "name" : "cpu_load_short" ,
254
+ "columns" : ["time" ,"value" ],
255
+ "values" : [
256
+ ["2015-01-29T21:55:43.702900257Z" , 0.55 ],
257
+ ["2015-01-29T21:55:43.702900257Z" , 23422 ],
258
+ ["2015-06-11T20:46:02Z" , 0.64 ]
259
+ ]
260
+ }
261
+ ]
262
+ }, {
263
+ "series" : [
264
+ {
265
+ "name" : "cpu_load_short" ,
266
+ "columns" : ["time" ,"count" ],
267
+ "values" : [
268
+ ["1970-01-01T00:00:00Z" , 3 ]
269
+ ]
270
+ }
271
+ ]
272
+ }
273
+ ]
274
+ }
275
+
276
+ pd1 = pd .DataFrame (
277
+ [[0.55 ], [23422.0 ], [0.64 ]], columns = ['value' ],
278
+ index = pd .to_datetime ([
279
+ "2015-01-29 21:55:43.702900257+0000" ,
280
+ "2015-01-29 21:55:43.702900257+0000" ,
281
+ "2015-06-11 20:46:02+0000" ])).tz_localize ('UTC' )
282
+ pd2 = pd .DataFrame (
283
+ [[3 ]], columns = ['count' ],
284
+ index = pd .to_datetime (["1970-01-01 00:00:00+00:00" ])).tz_localize ('UTC' )
285
+ expected = [{'cpu_load_short' :pd1 }, {'cpu_load_short' :pd2 }]
286
+
287
+
288
+ cli = DataFrameClient ('host' , 8086 , 'username' , 'password' , 'db' )
289
+ with _mocked_session (cli , 'GET' , 200 , data ):
290
+ result = cli .query (
291
+ "SELECT value FROM cpu_load_short WHERE region='us-west';" \
292
+ "SELECT count(value) FROM cpu_load_short WHERE region='us-west'" )
293
+ for r ,e in zip (result , expected ):
294
+ for k in e :
295
+ assert_frame_equal (e [k ], r [k ])
296
+
247
297
def test_query_with_empty_result (self ):
248
298
cli = DataFrameClient ('host' , 8086 , 'username' , 'password' , 'db' )
249
299
with _mocked_session (cli , 'GET' , 200 , {"results" : [{}]}):
0 commit comments