Browse Source

fix(discover): Always convert nan to 0 (#25899)

- We currently only convert nan values to 0 when there's transform_data,
  this change means we'll always convert nan to 0 since nan isn't valid
  JSON
- Fixes SENTRY-Q2M
William Mak 3 years ago
parent
commit
89de2c9c55

+ 1 - 2
src/sentry/snuba/discover.py

@@ -153,8 +153,7 @@ def transform_data(result, translated_columns, snuba_filter):
 
         return transformed
 
-    if len(translated_columns):
-        result["data"] = [get_row(row) for row in result["data"]]
+    result["data"] = [get_row(row) for row in result["data"]]
 
     rollup = snuba_filter.rollup
     if rollup and rollup > 0:

+ 7 - 0
tests/snuba/api/endpoints/test_organization_events_v2.py

@@ -3244,3 +3244,10 @@ class OrganizationEventsV2EndpointTest(APITestCase, SnubaTestCase):
         assert response.status_code == 200
         assert len(response.data["data"]) == 1
         assert "Link" not in response
+
+    def test_nan_result(self):
+        query = {"field": ["apdex(300)"], "project": [self.project.id], "query": f"id:{'0' * 32}"}
+        response = self.do_request(query)
+        assert response.status_code == 200
+        assert len(response.data["data"]) == 1
+        assert response.data["data"][0]["apdex_300"] == 0