-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fix(timeseries): Handle orderbys not in groupby #103547
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
Conversation
- 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
Codecov Report✅ All modified and coverable lines are covered by tests. 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]: |
There was a problem hiding this comment.
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.
error in snuba, but this updates the backend so we error instead so we can give the user a more friendly error message
we don't want that