Skip to content

Commit

Permalink
c
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 987fc61 commit ca2cf30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ python-rapidjson==1.8
redis==4.5.4
sentry-arroyo==2.19.4
sentry-kafka-schemas==0.1.129
sentry-protos==0.1.49
sentry-protos==0.1.51
sentry-redis-tools==0.3.0
sentry-relay==0.9.4
sentry-sdk==2.18.0
Expand Down
16 changes: 13 additions & 3 deletions snuba/web/rpc/common/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
)
if attr_key.type == AttributeKey.Type.TYPE_INT:
return f.CAST(column(attr_key.name[len("sentry.") :]), "Int64", alias=alias)
if attr_key.type == AttributeKey.Type.TYPE_FLOAT:
if (
attr_key.type == AttributeKey.Type.TYPE_FLOAT
or attr_key.type == AttributeKey.Type.TYPE_DOUBLE
):
return f.CAST(
column(attr_key.name[len("sentry.") :]), "Float64", alias=alias
)
Expand All @@ -133,7 +136,11 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
)

if attr_key.name in NORMALIZED_COLUMNS:
if NORMALIZED_COLUMNS[attr_key.name] == attr_key.type:
# the second if statement allows Sentry to send TYPE_DOUBLE to Snuba when Snuba still has to be backward compatible with TYPE_FLOATS
if NORMALIZED_COLUMNS[attr_key.name] == attr_key.type or (
attr_key.type == AttributeKey.Type.TYPE_DOUBLE
and NORMALIZED_COLUMNS[attr_key.name] == AttributeKey.Type.TYPE_FLOAT
):
return column(attr_key.name[len("sentry.") :], alias=attr_key.name)
raise BadSnubaRPCRequestException(
f"Attribute {attr_key.name} must be requested as {NORMALIZED_COLUMNS[attr_key.name]}, got {attr_key.type}"
Expand All @@ -144,7 +151,10 @@ def _build_label_mapping_key(attr_key: AttributeKey) -> str:
return SubscriptableReference(
alias=alias, column=column("attr_str"), key=literal(attr_key.name)
)
if attr_key.type == AttributeKey.Type.TYPE_FLOAT:
if (
attr_key.type == AttributeKey.Type.TYPE_FLOAT
or attr_key.type == AttributeKey.Type.TYPE_DOUBLE
):
return SubscriptableReference(
alias=alias, column=column("attr_num"), key=literal(attr_key.name)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ def _convert_results(
converters[column.label] = lambda x: AttributeValue(val_int=int(x))
elif column.key.type == AttributeKey.TYPE_FLOAT:
converters[column.label] = lambda x: AttributeValue(val_float=float(x))
elif column.key.type == AttributeKey.TYPE_DOUBLE:
converters[column.label] = lambda x: AttributeValue(val_double=float(x))
elif column.HasField("aggregation"):
converters[column.label] = lambda x: AttributeValue(val_float=float(x))
else:
Expand Down

0 comments on commit ca2cf30

Please sign in to comment.