Skip to content

Commit dd14647

Browse files
phacopsclaude
andauthored
feat(autocomplete): Return boolean values as part of the item attribute names endpoint (#7647)
Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 3bcb2b3 commit dd14647

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

snuba/datasets/configuration/events_analytics_platform/storages/eap_item_co_occurring_attrs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ schema:
2020

2121
{ name: attribute_keys_hash, type: Array, args: { inner_type: { type: UInt, args: { size: 64 } } } },
2222
{ name: attributes_string, type: Array, args: { inner_type: { type: String } } },
23-
{ name: attributes_float, type: Array, args: { inner_type: { type: String } } }
23+
{ name: attributes_float, type: Array, args: { inner_type: { type: String } } },
24+
{ name: attributes_bool, type: Array, args: { inner_type: { type: String } } }
2425
]
2526
local_table_name: eap_item_co_occurring_attrs_1_local
2627
dist_table_name: eap_item_co_occurring_attrs_1_dist

snuba/web/rpc/v1/endpoint_trace_item_attribute_names.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,32 @@ def get_co_occurring_attributes(
214214
),
215215
column("attributes_float"),
216216
)
217+
218+
bool_array = f.arrayMap(
219+
Lambda(
220+
None,
221+
("x",),
222+
f.tuple(
223+
"TYPE_BOOLEAN",
224+
column("x"),
225+
),
226+
),
227+
column("attributes_bool"),
228+
)
229+
217230
array_func = None
218231
if request.type == AttributeKey.Type.TYPE_STRING:
219232
array_func = string_array
220233
elif request.type in (
221234
AttributeKey.Type.TYPE_FLOAT,
222235
AttributeKey.Type.TYPE_DOUBLE,
223236
AttributeKey.Type.TYPE_INT,
224-
AttributeKey.Type.TYPE_BOOLEAN,
225237
):
226238
array_func = double_array
239+
elif request.type == AttributeKey.Type.TYPE_BOOLEAN:
240+
array_func = bool_array
227241
else:
228-
array_func = f.arrayConcat(string_array, double_array)
242+
array_func = f.arrayConcat(string_array, double_array, bool_array)
229243

230244
attr_filter = not_cond(
231245
in_cond(

tests/web/rpc/v1/test_endpoint_trace_item_attribute_names.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def generate_span_event_message(id: int) -> bytes:
5252
attributes[f"a_tag_{i:03}"] = AnyValue(string_value="blah")
5353
attributes[f"c_tag_{i:03}"] = AnyValue(string_value="blah")
5454
attributes[f"b_measurement_{i:03}"] = AnyValue(double_value=10)
55+
attributes[f"d_bool_{i:03}"] = AnyValue(bool_value=i % 2 == 0)
5556
return gen_item_message(
5657
start_timestamp=BASE_TIME + timedelta(minutes=id),
5758
attributes=attributes,
@@ -234,3 +235,28 @@ def test_basic_co_occurring_attrs(self) -> None:
234235
),
235236
]
236237
assert res.attributes == expected
238+
239+
def test_simple_boolean(self) -> None:
240+
req = TraceItemAttributeNamesRequest(
241+
meta=RequestMeta(
242+
project_ids=[1, 2, 3],
243+
organization_id=1,
244+
cogs_category="something",
245+
referrer="something",
246+
start_timestamp=Timestamp(seconds=int((BASE_TIME - timedelta(days=1)).timestamp())),
247+
end_timestamp=Timestamp(seconds=int((BASE_TIME + timedelta(days=1)).timestamp())),
248+
),
249+
limit=TOTAL_GENERATED_ATTR_PER_TYPE,
250+
type=AttributeKey.Type.TYPE_BOOLEAN,
251+
value_substring_match="d_bool",
252+
)
253+
res = EndpointTraceItemAttributeNames().execute(req)
254+
expected = []
255+
for i in range(TOTAL_GENERATED_ATTR_PER_TYPE):
256+
expected.append(
257+
TraceItemAttributeNamesResponse.Attribute(
258+
name=f"d_bool_{str(i).zfill(3)}",
259+
type=AttributeKey.Type.TYPE_BOOLEAN,
260+
)
261+
)
262+
assert res.attributes == expected

0 commit comments

Comments
 (0)