Skip to content

feat(eap): Allow arrays to be queried from EAP#7551

Merged
phacops merged 19 commits into
masterfrom
pierre/eap-work-around-no-json-column-support-in-driver
Dec 2, 2025
Merged

feat(eap): Allow arrays to be queried from EAP#7551
phacops merged 19 commits into
masterfrom
pierre/eap-work-around-no-json-column-support-in-driver

Conversation

@phacops

@phacops phacops commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

This will allow us to return array values stored in attributes_array when fetching a trace. Support to return arrays with containing different types were added to sentry-protos (getsentry/sentry-protos#153).

One caveat right now is clickhouse-driver doesn't support the JSON or Variant column types. The workaround for this right now is to encode as JSON and send the value back to Snuba as a string.

There is a PR opened which adds support but there's not a lot of activity. Perhaps we should fork clickhouse-driver and add support for the JSON type for a mid term solution, then upsrtream the result.

@phacops
phacops requested review from a team as code owners November 24, 2025 21:12
Comment on lines +488 to 492
attributes_array = _process_arrays(arrays)
for key, value in attributes_array.items():
add_attribute(k, v)

item = GetTraceResponse.Item(

This comment was marked as outdated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a real bug, was this come across in tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it was due to a late refactor before I commit (rename k/v to key/value) and didn't run the tests in-between.

@phacops

phacops commented Nov 27, 2025

Copy link
Copy Markdown
Contributor Author

Sentry needed to have some compatibility work done: getsentry/sentry#104063

@phacops
phacops requested a review from volokluev November 27, 2025 00:14
@phacops
phacops merged commit 16e075c into master Dec 2, 2025
34 checks passed
@phacops
phacops deleted the pierre/eap-work-around-no-json-column-support-in-driver branch December 2, 2025 19:05
manessaraj added a commit that referenced this pull request Apr 27, 2026
…7898)

Current implementation of arrays in TraceItemTable endpoint transforms
arrays as array of strings, and then only allows `LIKE/NOT_LIKE` filter
on them.

With this change, arrays will preserve their original type, and client
can filter EAP items by element of an array attribute.
To preserve the type, array is converted to JSON string,
(clickhouse-driver doesn't support Array(JSON) type, as discussed in
this [PR](#7551)), and post
processing of results recovers the original array by decoding JSON
string.

To filter, predicate maps arrays to corresponding type and use array
exists with element filter.

Example Clickhouse query is:
```

SELECT (
    cast(lower(leftPad(hex(item_id), if(
        greater(length(hex(item_id)), 16), 32, 16), '0')), 'String'
    ) AS `sentry.item_id_TYPE_STRING`
), (toJSONString(attributes_array.`tags`::Array(
    JSON)) AS tags_TYPE_ARRAY
)
FROM eap_items_1_local
WHERE in(
    project_id, [1, 2, 3]
)
AND equals(organization_id, 1)
AND less(
    timestamp, toDateTime('2026-04-24 14:00:00')
)
AND greaterOrEquals(timestamp, toDateTime('2026-04-24 08:00:00'))
AND arrayExists(x -> equals(lower(x), lower('error')), (arrayMap(x -> coalesce(
    x.`String`::Nullable(String), toString(x.`Int`::Nullable(Int64)), toString(x.`Double`::Nullable(Float64)), x.`Bool`::Nullable(String)), attributes_array.`tags`::Array(
        JSON)) AS tags_TYPE_ARRAY__array_members
    )
)
AND lessOrEquals(sampling_factor, 1)
AND greater(sampling_factor, 0)
AND equals(item_type, 1)
LIMIT 10001 OFFSET 0

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants