Skip to content

feat(attribute-values): Add counts to response and orderby#7960

Open
wmak wants to merge 1 commit into
masterfrom
wmak/feat/add-counts-to-attribute-values
Open

feat(attribute-values): Add counts to response and orderby#7960
wmak wants to merge 1 commit into
masterfrom
wmak/feat/add-counts-to-attribute-values

Conversation

@wmak
Copy link
Copy Markdown
Member

@wmak wmak commented May 22, 2026

  • This adds counts to the AttributeValues endpoint so its a part of the response and the default sort so we're getting the most common values
  • Also updates the protos to support this

- This adds counts to the AttributeValues endpoint so its a part of the
  response and the default sort so we're getting the most common values
- Also updates the protos to support this
@wmak wmak requested review from a team as code owners May 22, 2026 17:56
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 2 potential issues.

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 bf90686. Configure here.

)
return TraceItemAttributeValuesResponse(
values=values,
counts=counts,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor-based page token incompatible with new sort order

Medium Severity

The response page_token constructs a filter_offset cursor using attr_value > values[-1], which assumes results are sorted alphabetically by attr_value. The PR changed the primary sort to count() DESC, attr_value ASC, so values[-1] is no longer the alphabetically greatest value — it's just the last item in count-descending order. This makes the cursor semantically incorrect: it would skip values that belong on the next page or include values that don't. The offset-based path also doesn't account for the non-deterministic nature of count-based ordering across requests.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bf90686. Configure here.

name="attr_value",
expression=f.distinct(column(attr_value.alias, alias="attr_value")),
),
SelectedExpression(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Redundant distinct wrapper with GROUP BY clause

Low Severity

f.distinct() wrapping attr_value is now redundant because the new groupby=[column("attr_value")] already guarantees unique values. In ClickHouse, this generates SELECT DISTINCT ... GROUP BY ... where the DISTINCT is a no-op. Keeping both deduplication mechanisms is confusing and obscures the query's actual semantics — GROUP BY is the operative deduplication here (needed for count()).

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bf90686. Configure here.

Copy link
Copy Markdown
Contributor

@phacops phacops left a comment

Choose a reason for hiding this comment

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

The 2 cursor comments should be fixed before merging.

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