Skip to content

Commit

Permalink
receiving
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Chen authored and Rachel Chen committed Jan 16, 2025
1 parent 9f6bc7b commit e1e0951
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 40 deletions.
50 changes: 25 additions & 25 deletions src/sentry/search/eap/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/search/eap/spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import (
AttributeKey,
AttributeValue,
DoubleArray,
FloatArray,
IntArray,
StrArray,
VirtualColumnContext,
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/sentry/snuba/spans_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sentry.search.eap.constants import (
BOOLEAN,
DOUBLE,
FLOAT,
INT,
MAX_ROLLUP_POINTS,
STRING,
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions tests/sentry/search/eap/test_spans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
AttributeAggregation,
AttributeKey,
AttributeValue,
DoubleArray,
ExtrapolationMode,
FloatArray,
Function,
StrArray,
VirtualColumnContext,
Expand Down Expand Up @@ -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),
)
)

Expand Down Expand Up @@ -95,19 +95,19 @@ 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])),
)
)

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),
)
)

Expand Down

0 comments on commit e1e0951

Please sign in to comment.