diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java index af8a1820..c1e3a442 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/ExecutionTreeBuilder.java @@ -87,6 +87,11 @@ public QueryNode build() { entitiesRequest.getOffset(), entitiesRequest.getOrderByList()); executionContext.setSortAndPaginationNodeAdded(true); + } else { + // TODO: Add an or node on other sources, if there is order by on other sources + rootNode = + new OrNode( + List.of(rootNode, new DataFetcherNode(QS.name(), Filter.getDefaultInstance()))); } rootNode.acceptVisitor(new ExecutionContextBuilderVisitor(executionContext)); diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java index f6307b1b..f8cc3d24 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionContextBuilderVisitor.java @@ -55,7 +55,9 @@ public ExecutionContextBuilderVisitor(ExecutionContext executionContext) { public Void visit(DataFetcherNode dataFetcherNode) { String source = dataFetcherNode.getSource(); - executionContext.removePendingSelectionSource(source); + if (!source.equals("EDS")) { + executionContext.removePendingSelectionSource(source); + } // TODO: Currently, assumes that the order by attribute is also present in the selection set executionContext.removePendingSelectionSourceForOrderBy(source); // TODO: Remove redundant attributes for metric aggregation source for order by @@ -73,14 +75,14 @@ public Void visit(DataFetcherNode dataFetcherNode) { Set fetchedAttributes = sourceToSelectionAttributeMap.getOrDefault(source, Collections.emptySet()); - if (!executionContext.getPendingSelectionSources().isEmpty()) { - Set redundantPendingSelectionSources = - getRedundantPendingSelectionSources( - fetchedAttributes, - executionContext.getPendingSelectionSources(), - executionContext.getSourceToSelectionAttributeMap()); - redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource); - } +// if (!executionContext.getPendingSelectionSources().isEmpty()) { +// Set redundantPendingSelectionSources = +// getRedundantPendingSelectionSources( +// fetchedAttributes, +// executionContext.getPendingSelectionSources(), +// executionContext.getSourceToSelectionAttributeMap()); +// redundantPendingSelectionSources.forEach(executionContext::removePendingSelectionSource); +// } if (!executionContext.getPendingSelectionSourcesForOrderBy().isEmpty()) { Set redundantPendingSelectionSourcesForOrderBy = diff --git a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java index fe167699..f76961eb 100644 --- a/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java +++ b/gateway-service-impl/src/main/java/org/hypertrace/gateway/service/entity/query/visitor/ExecutionVisitor.java @@ -148,10 +148,16 @@ public EntityResponse visit(DataFetcherNode dataFetcherNode) { // fetching both attribute selections and metric order by selections for // optimized pagination - List attributeSelections = - executionContext - .getSourceToSelectionExpressionMap() - .getOrDefault(source, executionContext.getEntityIdExpressions()); + List attributeSelections = new ArrayList<>(); + if (!source.equals("EDS")) { + attributeSelections = + executionContext + .getSourceToSelectionExpressionMap() + .getOrDefault(source, executionContext.getEntityIdExpressions()); + } else { + attributeSelections = executionContext.getEntityIdExpressions(); + } + List metricOrderBySelections = executionContext .getSourceToMetricOrderByExpressionMap()