Skip to content

Commit 3008d2e

Browse files
committed
-> Fix for modality bug
1 parent 9a71f36 commit 3008d2e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

google_helpers/bigquery/bq_support.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ def insert_job_batch_and_get_results(cls, query_set):
587587
# Support for specifying a set of continuous numeric attributes to be presumed for BETWEEN clauses
588588
#
589589
# TODO: add support for DATETIME eg 6/10/2010
590+
@staticmethod
590591
def build_bq_filter_and_params(filters, comb_with='AND', param_suffix=None, with_count_toggle=False,
591592
field_prefix=None, type_schema=None, case_insens=True, continuous_numerics=None):
592593
if field_prefix and field_prefix[-1] != ".":
@@ -675,8 +676,13 @@ def build_bq_filter_and_params(filters, comb_with='AND', param_suffix=None, with
675676
is_btw = re.search('_e?btwe?', attr.lower()) is not None
676677
attr_name = attr[:attr.rfind('_')] if re.search('_[gl]te?|_e?btwe?|_eq', attr) else attr
677678
if attr_name not in attr_filters:
679+
operator = 'OR'
680+
if 'values' in values:
681+
# This is a fully qualified attribute which needs to have its definition broken out
682+
operator = values['op']
683+
values = values['values']
678684
attr_filters[attr_name] = {
679-
'OP': 'OR',
685+
'OP': operator,
680686
'filters': []
681687
}
682688
attr_filter_set = attr_filters[attr_name]['filters']
@@ -820,6 +826,11 @@ def build_bq_filter_and_params(filters, comb_with='AND', param_suffix=None, with
820826
filter_string += " OR ".join(btw_filter_strings)
821827
query_param = query_params
822828
else:
829+
if operator == 'AND' and len(values) > 1:
830+
# If an operator is to be AND'd with more than one value we must make an intersection statement on the higher-level entity
831+
# (i.e. select for studies which have series containing both values)
832+
# That cannot be performed here
833+
logger.warning("[WARNING] Multiple-value AND clauses require an intersection statement!")
823834
# Simple array param
824835
query_param['parameterType']['type'] = "ARRAY"
825836
query_param['parameterType']['arrayType'] = {

idc_collections/collex_metadata_utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2818,13 +2818,11 @@ def get_bq_metadata(filters, fields, data_version, sources_and_attrs=None, group
28182818
tables_in_query = []
28192819
joins = []
28202820
query_filters = []
2821-
non_related_filters = {}
28222821
fields = [field_clauses[image_table]] if image_table in field_clauses else []
28232822
if search_child_records_by:
28242823
child_record_search_field = search_child_records_by
28252824
if image_table in filter_attr_by_bq['sources']:
28262825
filter_set = {x: filters[x] for x in filters if x in filter_attr_by_bq['sources'][image_table]['list']}
2827-
non_related_filters = filter_set
28282826
if len(filter_set):
28292827
if may_need_intersect and len(filter_set.keys()) > 1:
28302828
for filter in filter_set:

0 commit comments

Comments
 (0)