Browse Source

ref(arithmetic): Remove restrictions to count_if conditions (#27392)

- This allows comparisons on count_if conditions regardless of column
  type, since clickhouse supports comparison on strings.
- This is to keep the frontend simpler since we won't have to show&hide
  conditions based on the column type
William Mak 3 years ago
parent
commit
78230cf1a7
2 changed files with 0 additions and 8 deletions
  1. 0 4
      src/sentry/search/events/fields.py
  2. 0 4
      tests/sentry/search/events/test_fields.py

+ 0 - 4
src/sentry/search/events/fields.py

@@ -351,7 +351,6 @@ def normalize_count_if_value(args: Mapping[str, str]) -> Union[float, str, int]:
     eg. duration = numeric_value, and not duration = string_value
     """
     column = args["column"]
-    condition = args["condition"]
     value = args["value"]
     if column == "transaction.duration" or is_measurement(column) or is_span_op_breakdown(column):
         duration_match = DURATION_PATTERN.match(value.strip("'"))
@@ -376,9 +375,6 @@ def normalize_count_if_value(args: Mapping[str, str]) -> Union[float, str, int]:
     # TODO: not supporting field aliases or arrays yet
     elif column in FIELD_ALIASES or column in ARRAY_FIELDS:
         raise InvalidSearchQuery(f"{column} is not supported by count_if")
-    # At this point only string or tag columns are left
-    elif condition not in ["equals", "notEquals"]:
-        raise InvalidSearchQuery(f"{condition} is not compatible with {column}")
     else:
         normalized_value = value
 

+ 0 - 4
tests/sentry/search/events/test_fields.py

@@ -1601,10 +1601,6 @@ class ResolveFieldListTest(unittest.TestCase):
             resolve_field_list(["count_if(stack.function, equals, test)"], eventstore.Filter())
         assert str(query_error.exception) == "stack.function is not supported by count_if"
 
-        with self.assertRaises(InvalidSearchQuery) as query_error:
-            resolve_field_list(["count_if(http.status_code, greater, test)"], eventstore.Filter())
-        assert str(query_error.exception) == "greater is not compatible with http.status_code"
-
         with self.assertRaises(InvalidSearchQuery) as query_error:
             resolve_field_list(
                 ["count_if(transaction.status, equals, fakestatus)"], eventstore.Filter()