ref(attrvalues): support array-of-string attributes and typed value_data - #8390
Open
MeredithAnya wants to merge 7 commits into
Open
ref(attrvalues): support array-of-string attributes and typed value_data#8390MeredithAnya wants to merge 7 commits into
MeredithAnya wants to merge 7 commits into
Conversation
MeredithAnya
force-pushed
the
meredith/EAP-698
branch
from
August 26, 2026 22:35
285051d to
e02dd53
Compare
MeredithAnya
marked this pull request as ready for review
August 26, 2026 22:41
MeredithAnya
commented
Aug 26, 2026
MeredithAnya
force-pushed
the
meredith/EAP-698
branch
from
August 27, 2026 18:35
e02dd53 to
a5d8e2c
Compare
MeredithAnya
added a commit
that referenced
this pull request
Aug 27, 2026
Related to #8390 We are going to be adding a `last_seen` to the `TraceItemAttributeValuesResponse` (among other things) but right now the inner query has no order by. We want to add to order by timestamp so that the 10000 we grab are the most recent, so that when we get the `last_seen` aka `max(timestamp)`, this actually represents the most recent data. However in order to get the benefit of `optimize_read_in_order` we need the ORDER BY be a prefix of the primary key. Since we use `project_ids IN ()` syntax, if we just have one project, order by timestamp doesn't optimize the query. So you'd need the full prefix `(organization_id, project_id, item_type, timestamp)` in the ORDER BY, and with multiple projects that might not make sense since you'd be getting data from one project ### examples **project_id = 1** ```EXPLAIN PIPELINE SELECT attributes_string_38['sentry.description'], timestamp FROM eap_items_1_local WHERE (project_id = 1) AND (organization_id = 1) AND (item_type = 1) ORDER BY timestamp DESC LIMIT 10 SETTINGS optimize_read_in_order = 1 Query id: ec4ecaf9-9d49-46dd-aea7-6d566cc2dc62 ┌─explain───────────────────────────────────────────────────────────────────────────────────┐ 1. │ (Expression) │ 2. │ ExpressionTransform │ 3. │ (Limit) │ 4. │ Limit │ 5. │ (Sorting) │ 6. │ MergingSortedTransform 2 → 1 │ 7. │ BufferChunks × 2 │ 8. │ (Expression) │ 9. │ ExpressionTransform × 2 │ 10. │ (Expression) │ 11. │ ExpressionTransform × 2 │ 12. │ (ReadFromMergeTree) │ 13. │ ReverseTransform │ 14. │ MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InReverseOrder) 0 → 1 │ 15. │ ReverseTransform │ 16. │ MergeTreeSelect(pool: ReadPoolInOrder, algorithm: InReverseOrder) 0 → 1 │ └───────────────────────────────────────────────────────────────────────────────────────────┘ 16 rows in set. Elapsed: 0.015 sec. ```` **project_id IN [1]** ``` EXPLAIN PIPELINE SELECT attributes_string_38['sentry.description'], timestamp FROM eap_items_1_local WHERE (project_id IN [1]) AND (organization_id = 1) AND (item_type = 1) ORDER BY timestamp DESC LIMIT 10 SETTINGS optimize_read_in_order = 1 Query id: 89de6449-8eee-4381-b8a2-50dfe3a98628 ┌─explain──────────────────────────────────────────────────────────────────────┐ 1. │ (Expression) │ 2. │ ExpressionTransform │ 3. │ (Limit) │ 4. │ Limit │ 5. │ (Sorting) │ 6. │ MergingSortedTransform 2 → 1 │ 7. │ MergeSortingTransform × 2 │ 8. │ LimitsCheckingTransform × 2 │ 9. │ PartialSortingTransform × 2 │ 10. │ (Expression) │ 11. │ ExpressionTransform × 2 │ 12. │ (Expression) │ 13. │ ExpressionTransform × 2 │ 14. │ (ReadFromMergeTree) │ 15. │ MergeTreeSelect(pool: ReadPool, algorithm: Thread) × 2 0 → 1 │ └──────────────────────────────────────────────────────────────────────────────┘ 15 rows in set. Elapsed: 0.022 sec. ```
MeredithAnya
force-pushed
the
meredith/EAP-698
branch
from
August 28, 2026 17:47
cb536ca to
15c57fe
Compare
pbhandari
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds array-of-string support to
TraceItemAttributeValues, and returns values astyped
AttributeValues with per-value metadata instead of plain strings.Depends on getsentry/sentry-protos#412 (released in
sentry-protos0.64.1, which this PR pins).What changed
TYPE_ARRAY_STRINGkeys are now enumerable.attributes_array_stringisadded to the type → column map, so requesting an array-of-string key returns
its distinct array values instead of
BadSnubaRPCRequestException.value_datafield. Every value is returned as aValueData { value: AttributeValue, count, last_seen }. Because the value is atyped
AttributeValue, arrays come back whole (val_array) and booleans comeback as real
val_bool— neither of which the string-only response couldexpress. Conversion reuses
get_converter_for_typefrom the table resolver(renamed from
_get_converter_for_type) so typing matchesTraceItemTable.last_seenper value. The outer query selectsmax(timestamp) AS last_seen, withtimestampprojected through the innerquery. Like
count(), this is an aggregate over the 10k-row sample the innerquery takes, not over every matching item — noted in the docstring.
datetimecoercion helper moved tocommon.pyasas_datetime, sharedwith
endpoint_trace_item_attribute_names.py(native driver returns adatetime, HTTP returns an ISO string).Backwards compatibility
The deprecated
values/countsfields are unchanged for string and booleankeys — booleans keep the lowercase
"true"/"false"form that callers feedback in as filter inputs. Array keys populate only
value_data: the stringfields cannot represent an array, and this endpoint rejected array keys before
value_dataexisted, so no caller can be relying on them. The page token is nowderived from
value_dataso array responses paginate correctly.