diff --git a/src/sentry/search/eap/constants.py b/src/sentry/search/eap/constants.py index 99c8ef020ed1ac..f2f5cbd128fb5b 100644 --- a/src/sentry/search/eap/constants.py +++ b/src/sentry/search/eap/constants.py @@ -39,32 +39,32 @@ # TODO: we need a datetime type # Maps search types back to types for the proto TYPE_MAP: dict[SearchType, AttributeKey.Type.ValueType] = { - "bit": DOUBLE, - "byte": DOUBLE, - "kibibyte": DOUBLE, - "mebibyte": DOUBLE, - "gibibyte": DOUBLE, - "tebibyte": DOUBLE, - "pebibyte": DOUBLE, - "exbibyte": DOUBLE, - "kilobyte": DOUBLE, - "megabyte": DOUBLE, - "gigabyte": DOUBLE, - "terabyte": DOUBLE, - "petabyte": DOUBLE, - "exabyte": DOUBLE, - "nanosecond": DOUBLE, - "microsecond": DOUBLE, - "millisecond": DOUBLE, - "second": DOUBLE, - "minute": DOUBLE, - "hour": DOUBLE, - "day": DOUBLE, - "week": DOUBLE, - "duration": DOUBLE, + "bit": FLOAT, + "byte": FLOAT, + "kibibyte": FLOAT, + "mebibyte": FLOAT, + "gibibyte": FLOAT, + "tebibyte": FLOAT, + "pebibyte": FLOAT, + "exbibyte": FLOAT, + "kilobyte": FLOAT, + "megabyte": FLOAT, + "gigabyte": FLOAT, + "terabyte": FLOAT, + "petabyte": FLOAT, + "exabyte": FLOAT, + "nanosecond": FLOAT, + "microsecond": FLOAT, + "millisecond": FLOAT, + "second": FLOAT, + "minute": FLOAT, + "hour": FLOAT, + "day": FLOAT, + "week": FLOAT, + "duration": FLOAT, "integer": INT, - "number": DOUBLE, - "percentage": DOUBLE, + "number": FLOAT, + "percentage": FLOAT, "string": STRING, "boolean": BOOLEAN, } diff --git a/src/sentry/search/eap/spans.py b/src/sentry/search/eap/spans.py index be9dea8b78b5e9..044a444d6f45fb 100644 --- a/src/sentry/search/eap/spans.py +++ b/src/sentry/search/eap/spans.py @@ -10,7 +10,7 @@ from sentry_protos.snuba.v1.trace_item_attribute_pb2 import ( AttributeKey, AttributeValue, - DoubleArray, + FloatArray, IntArray, StrArray, VirtualColumnContext, @@ -333,18 +333,18 @@ def _resolve_search_value( ) elif isinstance(value, (float, int)): return AttributeValue(val_int=int(value)) - elif column_type == constants.DOUBLE: + elif column_type == constants.FLOAT: if operator in constants.IN_OPERATORS: if isinstance(value, list): return AttributeValue( - val_double_array=DoubleArray(values=[val for val in value]) + val_float_array=FloatArray(values=[val for val in value]) ) else: raise InvalidSearchQuery( f"{value} is not a valid value for doing an IN filter" ) elif isinstance(value, float): - return AttributeValue(val_double=value) + return AttributeValue(val_float=value) elif column_type == constants.BOOLEAN: if operator in constants.IN_OPERATORS: raise InvalidSearchQuery( diff --git a/src/sentry/snuba/spans_rpc.py b/src/sentry/snuba/spans_rpc.py index 08fde8d8335c14..03bfc499910562 100644 --- a/src/sentry/snuba/spans_rpc.py +++ b/src/sentry/snuba/spans_rpc.py @@ -15,6 +15,7 @@ from sentry.search.eap.constants import ( BOOLEAN, DOUBLE, + FLOAT, INT, MAX_ROLLUP_POINTS, STRING, @@ -140,11 +141,10 @@ def run_table_query( result_value = result.val_str elif resolved_column.proto_type == INT: result_value = result.val_int + elif resolved_column.proto_type == FLOAT: + result_value = result.val_float elif resolved_column.proto_type == DOUBLE: - if result.WhichOneof("value") == "val_float": - result_value = result.val_float - if result.WhichOneof("value") == "val_double": - result_value = result.val_double + result_value = result.val_double elif resolved_column.proto_type == BOOLEAN: result_value = result.val_bool result_value = process_value(result_value) diff --git a/tests/sentry/search/eap/test_spans.py b/tests/sentry/search/eap/test_spans.py index 96ea63604bf315..baa04863cfa57e 100644 --- a/tests/sentry/search/eap/test_spans.py +++ b/tests/sentry/search/eap/test_spans.py @@ -3,8 +3,8 @@ AttributeAggregation, AttributeKey, AttributeValue, - DoubleArray, ExtrapolationMode, + FloatArray, Function, StrArray, VirtualColumnContext, @@ -51,9 +51,9 @@ def test_numeric_query(self): query, _ = self.resolver.resolve_query("ai.total_tokens.used:123") assert query == TraceItemFilter( comparison_filter=ComparisonFilter( - key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_DOUBLE), + key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_FLOAT), op=ComparisonFilter.OP_EQUALS, - value=AttributeValue(val_double=123), + value=AttributeValue(val_float=123), ) ) @@ -95,9 +95,9 @@ def test_in_numeric_filter(self): query, _ = self.resolver.resolve_query("ai.total_tokens.used:[123,456,789]") assert query == TraceItemFilter( comparison_filter=ComparisonFilter( - key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_DOUBLE), + key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_FLOAT), op=ComparisonFilter.OP_IN, - value=AttributeValue(val_double_array=DoubleArray(values=[123, 456, 789])), + value=AttributeValue(val_float_array=FloatArray(values=[123, 456, 789])), ) ) @@ -105,9 +105,9 @@ def test_greater_than_numeric_filter(self): query, _ = self.resolver.resolve_query("ai.total_tokens.used:>123") assert query == TraceItemFilter( comparison_filter=ComparisonFilter( - key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_DOUBLE), + key=AttributeKey(name="ai_total_tokens_used", type=AttributeKey.Type.TYPE_FLOAT), op=ComparisonFilter.OP_GREATER_THAN, - value=AttributeValue(val_double=123), + value=AttributeValue(val_float=123), ) )