Skip to content

Conversation

@wmak
Copy link
Member

@wmak wmak commented Nov 18, 2025

  • If a field is in the orderby but not in the groupbys we currently
    error in snuba, but this updates the backend so we error instead so we can give the user a more friendly error message
  • Also fixes a bug where timeseries could be passed to the orderby, but
    we don't want that

wmak added 2 commits November 17, 2025 15:55
- If a field is in the orderby but not in the groupbys we currently
  error in snuba, this updates the resolver to add the orderby field to
  the groupbys automatically for both table/topEvents
- Also fixes a bug where timeseries could be passed to the orderby, but
  we don't want that
@wmak wmak requested review from a team as code owners November 18, 2025 19:53
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Nov 18, 2025
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##           master   #103547       +/-   ##
============================================
+ Coverage   69.84%    80.68%   +10.84%     
============================================
  Files        9268      9240       -28     
  Lines      395667    394785      -882     
  Branches    25217     25057      -160     
============================================
+ Hits       276341    318522    +42181     
+ Misses     118428     75815    -42613     
+ Partials      898       448      -450     

if "timestamp" in raw_groupby:
raise ParseError("Cannot group by timestamp")
if raw_orderby:
if "timestamp" in [col.strip("-") for col in raw_orderby]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Bug: Incorrect use of strip instead of lstrip

The code uses strip("-") to remove the direction prefix from orderby columns, but this removes both leading and trailing hyphens. This differs from the standard pattern used throughout the codebase (like in rpc_dataset_common.py line 263) which uses lstrip("-") to only remove leading hyphens. If an orderby field name ends with a hyphen, strip would incorrectly remove it, causing the timestamp check to potentially fail or match the wrong field name.

Fix in Cursor Fix in Web

@wmak wmak merged commit a0dbe19 into master Nov 19, 2025
66 checks passed
@wmak wmak deleted the wmak/fix/handle-orderbys-not-in-groupby branch November 19, 2025 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants