-
Notifications
You must be signed in to change notification settings - Fork 8
fix(explore): order by on eds attributes #127
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #127 +/- ##
============================================
- Coverage 81.40% 81.16% -0.25%
- Complexity 1327 1328 +1
============================================
Files 125 125
Lines 5964 5982 +18
Branches 490 491 +1
============================================
Hits 4855 4855
- Misses 865 884 +19
+ Partials 244 243 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This comment has been minimized.
This comment has been minimized.
.../src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java
Outdated
Show resolved
Hide resolved
.../src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
Test Results3 tests - 358 3 ✔️ - 358 0s ⏱️ -10s Results for commit 53df6ea. ± Comparison against base commit 1997536. This pull request removes 373 tests.
♻️ This comment has been updated with latest results. |
.../src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java
Show resolved
Hide resolved
.../src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java
Show resolved
Hide resolved
// If there is a group by, specify a large limit and track actual limit, offset and order by | ||
// expression list, so we can compute these once the we get the results. | ||
if (requestContext.hasGroupBy()) { | ||
// Will need to do the ordering, limit and offset ourselves after we get the group by results |
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.
I'm a bit confused by this comment - aren't we pushing down the order here? Why can't we push down limit/offset?
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.
We aren't pushing order by to EDS in case of explore. EDS handler is only called when
- there is a group by, order by and selections on EDS. In this case, we handle it in memory. We can push group by to EDS along with order by, which is being called out by the TODO comment. That requires a separate effort
- there is an aggregated selection on EDS (like DISTINCT COUNT of APIs). There is no order by here. And, the limit in this case would be 1 inherently
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.
Second case makes sense.
First case - I thought we were pushing down group by (line 61). Discussed offline, but since this is the final query and isn't being joined with anything in memory (right?) we should be able to push everything down unless there's something missing support in EQS.
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.
Tried out different queries. We don't support ordering in document store on function expressions. Since, that's the case, we can't push limit/offset and order bys to EQS
We are already pushing group bys to EQS. Pushing limit and offset to EQS, only if there are no order by expressions (which shouldn't ideally be the case, since group by mostly comes with order by)
orderBy: [
{
aggregation: COUNT
size: null
direction: DESC
keyExpression: { key: "name" }
}
]
// If there is a group by, specify a large limit and track actual limit, offset and order by | ||
// expression list, so we can compute these once the we get the results. | ||
if (requestContext.hasGroupBy()) { | ||
// Will need to do the ordering, limit and offset ourselves after we get the group by results |
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.
Second case makes sense.
First case - I thought we were pushing down group by (line 61). Discussed offline, but since this is the final query and isn't being joined with anything in memory (right?) we should be able to push everything down unless there's something missing support in EQS.
// If there are order by expressions, specify a large limit and track actual limit, offset and | ||
// order by | ||
// expression list, so we can compute these once we get the results. | ||
if (!requestContext.getOrderByExpressions().isEmpty()) { |
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.
Can we move this code into addLimitAndOffset? It's confusing that we set the limit and offset unconditionally (in addLimitAndOffset), then conditionally overwrite them in the top level buildRequest call.
Also whether we push down or not will influence response processing. We should make sure we're in sync (i.e. have common code or state so we only evaluate the condition in one place in code).
Description
Order by on EDS attributes in explore, had missing order by expressions set on the explore request context, which are needed later to group by, and order in memory later
Testing
Verified the changes end to end