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

Commit

Permalink
adding order by
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-bansal committed Jun 10, 2024
1 parent 93b96e1 commit 90c9295
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.hypertrace.entity.query.service.v1.ColumnMetadata;
import org.hypertrace.entity.query.service.v1.EntityQueryRequest;
import org.hypertrace.entity.query.service.v1.Expression;
import org.hypertrace.entity.query.service.v1.Expression.Builder;
import org.hypertrace.entity.query.service.v1.Filter;
import org.hypertrace.entity.query.service.v1.Function;
import org.hypertrace.entity.query.service.v1.LiteralConstant;
Expand Down Expand Up @@ -133,6 +134,19 @@ public static Operator convertOperator(
return Operator.valueOf(operator.name());
}

public static OrderByExpression.Builder convertToEntityServiceOrderByExpression(
org.hypertrace.gateway.service.v1.common.OrderByExpression orderByExpression) {
Builder expressionBuilder = convertToEntityServiceExpression(orderByExpression.getExpression());
return OrderByExpression.newBuilder()
.setExpression(expressionBuilder)
.setOrder(convertToEntityServiceSortOrder(orderByExpression.getOrder()));

Check warning on line 142 in gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/EntityServiceAndGatewayServiceConverter.java

View check run for this annotation

Codecov / codecov/patch

gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/EntityServiceAndGatewayServiceConverter.java#L139-L142

Added lines #L139 - L142 were not covered by tests
}

public static SortOrder convertToEntityServiceSortOrder(
org.hypertrace.gateway.service.v1.common.SortOrder sortOrder) {
return SortOrder.valueOf(sortOrder.name());

Check warning on line 147 in gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/EntityServiceAndGatewayServiceConverter.java

View check run for this annotation

Codecov / codecov/patch

gateway-service-impl/src/main/java/org/hypertrace/gateway/service/common/converters/EntityServiceAndGatewayServiceConverter.java#L147

Added line #L147 was not covered by tests
}

public static Expression.Builder convertToEntityServiceExpression(
org.hypertrace.gateway.service.v1.common.Expression expression) {
Expression.Builder builder = Expression.newBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,24 @@ private EntityQueryRequest buildRequest(
.setFilter(buildFilter(exploreRequest, entityIdAttributeIds, entityIds));

addGroupBys(exploreRequest, builder);
addSortBy(exploreRequest, builder);
addSelections(requestContext, exploreRequest, builder);
builder.setLimit(exploreRequest.getLimit());
builder.setOffset(exploreRequest.getOffset());
return builder.build();
}

private void addSortBy(ExploreRequest exploreRequest, EntityQueryRequest.Builder builder) {
List<org.hypertrace.gateway.service.v1.common.OrderByExpression> orderBys =
exploreRequest.getOrderByList();
orderBys.forEach(
orderBy ->
builder.addOrderBy(
EntityServiceAndGatewayServiceConverter.convertToEntityServiceOrderByExpression(

Check warning on line 183 in gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java

View check run for this annotation

Codecov / codecov/patch

gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java#L182-L183

Added lines #L182 - L183 were not covered by tests
orderBy)
.build()));

Check warning on line 185 in gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java

View check run for this annotation

Codecov / codecov/patch

gateway-service-impl/src/main/java/org/hypertrace/gateway/service/explore/entity/EntityServiceEntityFetcher.java#L185

Added line #L185 was not covered by tests
}

private void addGroupBys(ExploreRequest exploreRequest, EntityQueryRequest.Builder builder) {
List<org.hypertrace.gateway.service.v1.common.Expression> groupBys =
ExpressionReader.getAttributeExpressions(exploreRequest.getGroupByList());
Expand Down

0 comments on commit 90c9295

Please sign in to comment.