Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc): Only groupby when needed #81403

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/sentry/snuba/spans_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def run_table_query(
descending=orderby_column.startswith("-"),
)
)
has_aggregations = any(
col for col in columns if isinstance(col.proto_definition, AttributeAggregation)
)

labeled_columns = [categorize_column(col) for col in columns]

Expand All @@ -74,11 +77,15 @@ def run_table_query(
meta=meta,
filter=query,
columns=labeled_columns,
group_by=[
col.proto_definition
for col in columns
if isinstance(col.proto_definition, AttributeKey)
],
group_by=(
[
col.proto_definition
for col in columns
if isinstance(col.proto_definition, AttributeKey)
]
if has_aggregations
else []
),
order_by=resolved_orderby,
limit=limit,
virtual_column_contexts=[context for context in contexts if context is not None],
Expand Down
Loading