Skip to content

feat(explore): support numeric comparison ops on TYPE_ARRAY keys#7935

Open
manessaraj wants to merge 1 commit into
masterfrom
sarajmanes/feat/EXP-945_query_support_for_neumerical_types
Open

feat(explore): support numeric comparison ops on TYPE_ARRAY keys#7935
manessaraj wants to merge 1 commit into
masterfrom
sarajmanes/feat/EXP-945_query_support_for_neumerical_types

Conversation

@manessaraj
Copy link
Copy Markdown
Contributor

Enable field[*]:>N / <N / >=N / <=N against TYPE_ARRAY columns in the RPC layer. Previously rejected: only =/!=/LIKE were allowed.

Example generated query (from TestArrayWildcardSearch::test_trace_item_table_array_op_greater_than_int,
filter frame_linenos[*]:>50):

    SELECT
        cast(lower(leftPad(hex(item_id), ..., '0')), 'String')
            AS `sentry.item_id_TYPE_STRING`,
        toJSONString(attributes_array.`frame_linenos`::Array(JSON))
            AS frame_linenos_TYPE_ARRAY
    FROM eap_items_1_local
    WHERE in(project_id, [1, 2, 3])
      AND equals(organization_id, 1)
      AND less(timestamp, toDateTime('2026-05-11 15:00:00'))
      AND greaterOrEquals(timestamp, toDateTime('2026-05-11 09:00:00'))
      AND arrayExists(x -> greater(x.`Int`::Nullable(Int64), 50),
                      attributes_array.`frame_linenos`::Array(JSON))
      AND equals(item_type, 1)
    LIMIT 10001 OFFSET 0

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 11, 2026

EXP-945

@manessaraj manessaraj marked this pull request as ready for review May 11, 2026 16:21
@manessaraj manessaraj requested review from a team as code owners May 11, 2026 16:21
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e729799. Configure here.

if v.WhichOneof("value") not in _NUMBER_VALUE_TYPES:
raise BadSnubaRPCRequestException(
f"{ComparisonFilter.Op.Name(op)} on array keys requires a numeric value"
"(val_int, val_float, val_double)"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing space in error message string concatenation

Low Severity

The error message uses implicit Python string concatenation between the f-string on line 375 and the plain string on line 376, but there's no space between "value" and "(val_int...". The resulting message reads "...requires a numeric value(val_int, val_float, val_double)" instead of "...requires a numeric value (val_int, val_float, val_double)". The test regex match="on array keys requires a numeric value" still passes because it doesn't cover the parenthesized suffix, so this won't be caught by tests.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e729799. Configure here.

Copy link
Copy Markdown
Contributor

@onewland onewland left a comment

Choose a reason for hiding this comment

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

The idea behind this change is suspect to me (that it's valuable to our users to be able to do comparison operations to filter rows by index-unspecified array elements) but this approach is acceptable if we are stipulating that this functionality itself is useful.

I would not expect it to perform well (in terms of rows processed/s) as a filter, but that might be fine if your other filters narrow the search enough.

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