@@ -369,12 +369,12 @@ def select(self, query_filter, where=None):
369
369
if cache_info is None :
370
370
self .cache_data (query_filter )
371
371
cache_info = self .cache_info (query_filter )
372
+
372
373
start_row , end_row = cache_info
373
- if not where :
374
- where = None
375
-
376
- result = store_select (self .store , self .localpath , where = where ,
377
- start = start_row , stop = end_row )
374
+
375
+ #removed start_row, end_row
376
+ result = store_select (self .store , self .localpath , where = where )
377
+ # start=start_row, stop=end_row)
378
378
return result
379
379
380
380
def cache_query (self , query_filter ):
@@ -403,11 +403,13 @@ def store_cache_spec(self, query_filter, start_row, end_row):
403
403
write_pandas (self .store , 'cache_spec' , data , {}, 1.1 ,
404
404
replace = False )
405
405
406
+
406
407
def cache_info (self , query_filter ):
407
408
hashval = self .gethashval (query_filter )
408
409
try :
409
- result = store_select (self .store , 'cache_spec' ,
410
- where = [('hashval' , hashval )])
410
+ #rewriting where statement for 0.13 pandas style
411
+ result = store_select (self .store , 'cache_spec' ,
412
+ where = 'hashval=="{}"' .format (hashval ))
411
413
except KeyError :
412
414
return None
413
415
if result is None :
@@ -446,14 +448,13 @@ def init_from_file(self):
446
448
setattr (self , name , column (name ))
447
449
448
450
def select (self , query_filter , where = None , ** kwargs ):
449
-
450
451
ignore_cache = kwargs .get ('IgnoreCache' ,None )
451
452
if ignore_cache :
452
453
query = self .compiled_query (query_filter ,kwargs )
453
454
return query
454
455
455
-
456
- if 'date' not in kwargs . keys () :
456
+ dateKeys = [ k for k in kwargs . keys () if 'date' in k ]
457
+ if not dateKeys :
457
458
#no dates in query
458
459
459
460
fs = FlexibleSqlCaching (self )
@@ -464,11 +465,9 @@ def select(self, query_filter, where=None, **kwargs):
464
465
return result
465
466
466
467
else :
467
- dateKeys = [k for k in kwargs .keys () if 'date' in k ]
468
468
dateKeys = sorted (dateKeys )
469
469
start_date , end_date = kwargs [dateKeys [0 ]], kwargs [dateKeys [1 ]]
470
470
471
-
472
471
result = self .cache_info (query_filter ,start_date , end_date )
473
472
474
473
if result is None :
@@ -500,11 +499,11 @@ def store_cache_spec(self, query_filter, start_row, end_row, start_date, end_dat
500
499
def cache_info (self , query_filter , start_date , end_date ):
501
500
hashval = self .gethashval (query_filter )
502
501
try :
503
-
504
502
# print self.store['/cache_spec']
505
- result = store_select (self .store , 'cache_spec' ,
506
- where = [('hashval' , hashval ),
507
- ('start_date' ,start_date )])
503
+ # result = store_select(self.store, 'cache_spec',
504
+ # where=[('hashval', hashval),
505
+ # ('start_date',start_date)])
506
+
508
507
start_date = pd .Timestamp (start_date )
509
508
end_date = pd .Timestamp (end_date )
510
509
@@ -562,7 +561,6 @@ def cache_data(self, query_params, start_date, end_date):
562
561
break ;
563
562
564
563
all_query = and_ (query_params ,column (col_date ) >= start_date , column (col_date ) <= end_date )
565
-
566
564
q = self .cache_query (all_query )
567
565
log .debug (str (q ))
568
566
@@ -582,7 +580,6 @@ def cache_data(self, query_params, start_date, end_date):
582
580
db_string_types = db_string_types ,
583
581
db_datetime_types = db_datetime_types
584
582
)
585
-
586
583
self .min_itemsize = min_itemsize
587
584
self .finalize_min_itemsize ()
588
585
overrides = self .col_types
@@ -592,6 +589,7 @@ def cache_data(self, query_params, start_date, end_date):
592
589
starting_row = self .table .nrows
593
590
except AttributeError :
594
591
starting_row = 0
592
+
595
593
write_pandas_hdf_from_cursor (self .store , self .localpath , cur ,
596
594
columns , self .min_itemsize ,
597
595
dtype_overrides = overrides ,
@@ -602,19 +600,17 @@ def cache_data(self, query_params, start_date, end_date):
602
600
ending_row = self .table .nrows
603
601
except AttributeError :
604
602
ending_row = 0
605
-
606
603
self .store_cache_spec (query_params , starting_row , ending_row , start_date , end_date )
607
604
608
605
609
606
def munge_tables (self , hashval , start_date , end_date ):
610
607
611
608
store = self .store
612
- store .select ('cache_spec' , where = [('hashval' , hashval )])
609
+ # store.select('cache_spec', where=[('hashval', hashval)])
613
610
614
611
store ['/cache_spec' ][['start_date' ,'end_date' ]].sort (['start_date' ])
615
-
616
- df_min = store .select ('cache_spec' , where = [('start_date' , '<=' , start_date )]).reset_index ()
617
- df_max = store .select ('cache_spec' , where = [('end_date' , '<=' , end_date )]).reset_index ()
612
+ df_min = store_select (store , 'cache_spec' , where = [('start_date' , '<=' , start_date )]).reset_index ()
613
+ df_max = store_select (store , 'cache_spec' , where = [('end_date' , '<=' , end_date )]).reset_index ()
618
614
619
615
df_total = df_min .append (df_max )
620
616
df_total .drop_duplicates ('_end_row' ,inplace = True )
@@ -626,8 +622,7 @@ def munge_tables(self, hashval, start_date, end_date):
626
622
for s in ss_vals :
627
623
start_row = s [0 ]
628
624
end_row = s [1 ]
629
-
630
- temp = store .select (self .localpath ,
625
+ temp = store_select (store , self .localpath ,
631
626
start = start_row , stop = end_row )
632
627
temp .head ()
633
628
0 commit comments