31
31
require_all ,
32
32
require_any ,
33
33
)
34
+ from .._db import sql_table_has_columns
34
35
from .._pandas import as_pandas
35
36
from .covidcast_utils import compute_trend , compute_trends , compute_correlations , compute_trend_value , CovidcastMetaEntry , AllSignalsMap
36
37
from ..utils import shift_time_value , date_to_time_value , time_value_to_iso
@@ -134,7 +135,12 @@ def handle():
134
135
q = QueryBuilder ("covidcast" , "t" )
135
136
136
137
fields_string = ["geo_value" , "signal" ]
137
- fields_int = ["time_value" , "direction" , "issue" , "lag" , "missing_value" , "missing_stderr" , "missing_sample_size" ]
138
+ fields_int = ["time_value" , "direction" , "issue" , "lag" ]
139
+
140
+ missing_fields = ["missing_value" , "missing_stderr" , "missing_sample_size" ]
141
+ if sql_table_has_columns ("covidcast" , missing_fields ):
142
+ fields_int .extend (missing_fields )
143
+
138
144
fields_float = ["value" , "stderr" , "sample_size" ]
139
145
if is_compatibility_mode ():
140
146
q .set_order ("signal" , "time_value" , "geo_value" , "issue" )
@@ -144,6 +150,7 @@ def handle():
144
150
q .set_order ("source" , "signal" , "time_type" , "time_value" , "geo_type" , "geo_value" , "issue" )
145
151
q .set_fields (fields_string , fields_int , fields_float )
146
152
153
+
147
154
# basic query info
148
155
# data type of each field
149
156
# build the source, signal, time, and location (type and id) filters
0 commit comments