Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

fix(explore): order by on eds attributes #127

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

skjindal93
Copy link
Contributor

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

@skjindal93 skjindal93 requested a review from a team April 4, 2022 10:53
@codecov
Copy link

codecov bot commented Apr 4, 2022

Codecov Report

Merging #127 (9680686) into main (1997536) will decrease coverage by 0.25%.
The diff coverage is 9.09%.

❗ Current head 9680686 differs from pull request most recent head 53df6ea. Consider uploading reports for the commit 53df6ea to get more accurate results

@@             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     
Flag Coverage Δ
unit 81.16% <9.09%> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...rtrace/gateway/service/explore/ExploreService.java 82.85% <100.00%> (+0.91%) ⬆️
...y/service/explore/entity/EntityRequestHandler.java 84.95% <ø> (ø)
...ice/explore/entity/EntityServiceEntityFetcher.java 7.31% <4.76%> (-0.75%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link

Unit Test Results

  60 files  ±0    60 suites  ±0   8s ⏱️ -1s
337 tests ±0  337 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f9483a2. ± Comparison against base commit 9d710f8.

@skjindal93 skjindal93 requested a review from a team as a code owner August 27, 2023 09:49
@github-actions
Copy link

github-actions bot commented Aug 27, 2023

Test Results

3 tests   - 358   3 ✔️  - 358   0s ⏱️ -10s
1 suites  -   65   0 💤 ±    0 
1 files    -   65   0 ±    0 

Results for commit 53df6ea. ± Comparison against base commit 1997536.

This pull request removes 373 tests.

      long: 60
      string: "PT1M"
      valueType: LONG
      valueType: STRING
    alias: "numCalls"
    columnName: "SERVICE.numCalls"
    value {
    }
  columnIdentifier {
…

♻️ This comment has been updated with latest results.

// 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
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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" }
  }
]

gateway-service-factory/build.gradle.kts Outdated 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
Copy link
Contributor

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()) {
Copy link
Contributor

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants