Skip to content

Commit

Permalink
fix(spans): Add group_raw to HexIntColumnProcessor (#4459)
Browse files Browse the repository at this point in the history
Add group_raw to the HexIntColumnProcessor because
right now we return the raw int and we'd like to return
the hash instead as we do with group
  • Loading branch information
shruthilayaj authored Jul 4, 2023
1 parent e670cda commit 9d7a21b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion snuba/datasets/configuration/spans/storages/spans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ query_processors:
columns: [transaction_id, trace_id]
- processor: HexIntColumnProcessor
args:
columns: [span_id, parent_span_id, segment_id, group]
columns: [span_id, parent_span_id, segment_id, group, group_raw]
- processor: MappingOptimizer
args:
column_name: tags
Expand Down
20 changes: 20 additions & 0 deletions tests/test_spans_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,23 @@ def test_granularity_processor_gets_applied(self) -> None:
data = json.loads(response.data)
assert response.status_code == 200, response.data
assert data["sql"].startswith("SELECT (toStartOfHour(end_timestamp")

def test_hex_int_column_processor_gets_applied_to_group_raw(self) -> None:
from_date = (self.base_time - self.skew).isoformat()
to_date = (self.base_time + self.skew).isoformat()
response = self._post_query(
f"""MATCH (spans)
SELECT group_raw,
count() AS aggregate
BY group_raw
WHERE project_id = 1
AND timestamp >= toDateTime('{from_date}')
AND timestamp < toDateTime('{to_date}')
GRANULARITY 60
"""
)
data = json.loads(response.data)
assert response.status_code == 200, response.data
assert data["sql"].startswith(
"SELECT (lower(hex(group_raw)) AS _snuba_group_raw)"
)

0 comments on commit 9d7a21b

Please sign in to comment.