-
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?
Changes from 9 commits
0a5e0c5
e3f5535
f9483a2
735f2b4
998534a
a5826ce
d9c4e9c
b4b2851
7c6a52b
4c5f357
9680686
53df6ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,12 +18,15 @@ | |
| import org.hypertrace.gateway.service.common.converters.EntityServiceAndGatewayServiceConverter; | ||
| import org.hypertrace.gateway.service.common.util.AttributeMetadataUtil; | ||
| import org.hypertrace.gateway.service.common.util.ExpressionReader; | ||
| import org.hypertrace.gateway.service.common.util.OrderByUtil; | ||
| import org.hypertrace.gateway.service.entity.config.EntityIdColumnsConfigs; | ||
| import org.hypertrace.gateway.service.explore.ExploreRequestContext; | ||
| import org.hypertrace.gateway.service.v1.common.OrderByExpression; | ||
| import org.hypertrace.gateway.service.v1.explore.ExploreRequest; | ||
|
|
||
| public class EntityServiceEntityFetcher { | ||
| private static final int DEFAULT_ENTITY_REQUEST_LIMIT = 10_000; | ||
|
|
||
| private final AttributeMetadataProvider attributeMetadataProvider; | ||
| private final EntityIdColumnsConfigs entityIdColumnsConfigs; | ||
| private final EntityQueryServiceClient entityQueryServiceClient; | ||
|
|
@@ -57,7 +60,20 @@ private EntityQueryRequest buildRequest( | |
|
|
||
| addGroupBys(exploreRequest, builder); | ||
| addSelections(requestContext, exploreRequest, builder); | ||
|
|
||
| // Ideally, needs the limit and offset for group by, since the fetcher is only triggered when | ||
| // there is a group by, or a single aggregation selection. A single aggregated selection would | ||
| // always return a single result (i.e. limit 1) | ||
| builder.setLimit(DEFAULT_ENTITY_REQUEST_LIMIT); | ||
|
|
||
| // TODO: Push group by down to EQS | ||
| // 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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) |
||
| requestContext.setOrderByExpressions(getRequestOrderByExpressions(exploreRequest)); | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
|
|
||
|
|
@@ -126,4 +142,9 @@ private Filter.Builder buildFilter( | |
|
|
||
| return filterBuilder.addAllChildFilter(entityIdsInFilter); | ||
| } | ||
|
|
||
| private List<OrderByExpression> getRequestOrderByExpressions(ExploreRequest request) { | ||
| return OrderByUtil.matchOrderByExpressionsAliasToSelectionAlias( | ||
| request.getOrderByList(), request.getSelectionList(), request.getTimeAggregationList()); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.