@@ -3450,6 +3450,61 @@ def test_select_iterator_non_complete_8014(self):
3450
3450
rexpected = expected [expected .index > end_dt ]
3451
3451
tm .assert_frame_equal (rexpected , result )
3452
3452
3453
+ def test_select_iterator_many_empty_frames (self ):
3454
+
3455
+ # GH 8014
3456
+ # using iterator and where clause can return many empty
3457
+ # frames.
3458
+ chunksize = 1e4
3459
+
3460
+ # with iterator, range limited to the first chunk
3461
+ with ensure_clean_store (self .path ) as store :
3462
+
3463
+ expected = tm .makeTimeDataFrame (100000 , 'S' )
3464
+ _maybe_remove (store , 'df' )
3465
+ store .append ('df' ,expected )
3466
+
3467
+ beg_dt = expected .index [0 ]
3468
+ end_dt = expected .index [chunksize - 1 ]
3469
+
3470
+ # select w/iterator and where clause, single term, begin of range
3471
+ where = "index >= '%s'" % beg_dt
3472
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
3473
+ # should be 1, is 10
3474
+ tm .assert_equal (1 , len (results ))
3475
+ result = concat (results )
3476
+ rexpected = expected [expected .index >= beg_dt ]
3477
+ tm .assert_frame_equal (rexpected , result )
3478
+
3479
+ # select w/iterator and where clause, single term, end of range
3480
+ where = "index <= '%s'" % end_dt
3481
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
3482
+ # should be 1, is 10
3483
+ tm .assert_equal (1 , len (results ))
3484
+ result = concat (results )
3485
+ rexpected = expected [expected .index <= end_dt ]
3486
+ tm .assert_frame_equal (rexpected , result )
3487
+
3488
+ # select w/iterator and where clause, inclusive range
3489
+ where = "index >= '%s' & index <= '%s'" % (beg_dt , end_dt )
3490
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
3491
+ # should be 1, is 10
3492
+ tm .assert_equal (1 , len (results ))
3493
+ result = concat (results )
3494
+ rexpected = expected [(expected .index >= beg_dt ) & (expected .index <= end_dt )]
3495
+ tm .assert_frame_equal (rexpected , result )
3496
+
3497
+ # select w/iterator and where clause which selects
3498
+ # *nothing*.
3499
+ #
3500
+ # To be consistent with Python idiom I suggest this should
3501
+ # return [] e.g. `for e in []: print True` never prints
3502
+ # True.
3503
+ where = "index <= '%s' & index >= '%s'" % (beg_dt , end_dt )
3504
+ results = [ s for s in store .select ('df' ,where = where ,chunksize = chunksize ) ]
3505
+ # should be []
3506
+ tm .assert_equal (0 , len (results ))
3507
+
3453
3508
def test_retain_index_attributes (self ):
3454
3509
3455
3510
# GH 3499, losing frequency info on index recreation
0 commit comments