Conversation
This comment has been minimized.
This comment has been minimized.
Codecov Report
@@ Coverage Diff @@
## main #116 +/- ##
============================================
+ Coverage 76.95% 77.60% +0.65%
- Complexity 1115 1133 +18
============================================
Files 106 106
Lines 5077 5158 +81
Branches 436 426 -10
============================================
+ Hits 3907 4003 +96
+ Misses 981 972 -9
+ Partials 189 183 -6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
| AttributeExpression.newBuilder().setAttributeId(columnIdentifier.getColumnName()); | ||
|
|
||
| Optional.of(columnIdentifier.getAlias()) | ||
| .filter(Predicate.not(String::isEmpty)) |
There was a problem hiding this comment.
Curious Q: Did we observe any issue as prior we were not checking for an empty string? If we are doing this here, do we need to check if not empty in the above function - convertToQueryAttributeExpression (line 295/296)?
There was a problem hiding this comment.
On 295, we do this check in a more formal way via hasAlias(). This works because on the new GW AttributeExpression message, alias is optional and thus generates the presence check. On the existing column identifier message being used here, because it is not optional the only way to check if it's set is comparing it to the default value (empty string).
Prior to this change, when going from one col identifier to another, the check wasn't needed more or less for the same reason. The QS version of alias didn't support the presence check leaving no difference between an unset alias and one set to an empty string. Now, if we propagated the empty string col identifier alias into attribute expression, .hasAlias() would incorrectly return true.
A bit long winded, but does that make sense?
| .orElse(false); | ||
| } | ||
|
|
||
| private static Optional<String> getSelectionAttributeId(Expression expression) { |
There was a problem hiding this comment.
should we rename this getSelectionAttributeId -> getAttributeId? The first time, I was reading, I read something to do with the selection clause. What do you think?
There was a problem hiding this comment.
What I was trying to convey here (and I think is missing from getAttributeId) is that this only extracts attribute id from a col identifier or attribute expression, rather than an order by, function etc. I had taken to lumping the two of them together in naming as "selection", but I can see how that would be unclear. Any ideas that could better convey that distinction?
There was a problem hiding this comment.
I see it's a bit tricky as the two names are very different 'columnIdentifier' and 'attributeExpression'. Not able to come up with a good name so that it is readable in the above context. Maybe any of the below (if not we can use the same name for now).
<get|fetch|extract>AttributeIdFromColumnOrAttributeExpression
getAttributeIdFromAttributeSelection - As we are using, somewhere attributeSelection which refers to Column/AttributeExpression
There was a problem hiding this comment.
I buy getAttributeIdFromAttributeSelection - will update to that.
| expression -> | ||
| !mappedEntityIdAttributeIds.contains( | ||
| expression.getColumnIdentifier().getColumnName())) | ||
| entitiesRequest |
There was a problem hiding this comment.
Curious Q: Why did we remove this filter !mappedEntityIdAttributeIds? Does this mean we will add those selections twice?
There was a problem hiding this comment.
The reason it was removed was that we were dropping alias information here - if the caller requested an id attribute by a different alias, the existing implementation was removing that. I had figured that duplicating a selection wouldn't have any significant impact, and wasn't worth the complexity.
That said, in the QS version of the entity fetcher, I believe I ended up with a better solution where I dropped dupe requests and used the aliases at the end to remap them back ( https://github.com/hypertrace/gateway-service/pull/116/files/ea0965d95e98c7caaa83dea5501dc17437362189#diff-11defa5d01d0ff51c801f8ea113e9b9100328b20e0d3073b3faae6bb38c31626R241-R246 ) so let me revisit this and see if that's feasible here.
There was a problem hiding this comment.
Followed up with the same solution here.
| .map( | ||
| expression -> | ||
| Map.entry( | ||
| ExpressionReader.getSelectionResultName(expression).orElseThrow(), |
There was a problem hiding this comment.
Can we rename this as ExpressionReader.getSelectionAttributeId -> ExpressionReader.getAttributeId?
There was a problem hiding this comment.
| if (selectionResultNames.containsKey(FROM_ENTITY_ID_ATTRIBUTE_ID)) { | ||
| interaction.putAttribute( | ||
| FROM_ENTITY_ID_ATTRIBUTE_ID, | ||
| selectionResultNames.get(FROM_ENTITY_ID_ATTRIBUTE_ID), |
There was a problem hiding this comment.
Prior, the alias was not used, was that taken care of some other place, or did this change fix the case of not handling alias?
There was a problem hiding this comment.
Correct, aliases were not working here before this change (well more accurately, graphql was using attribute IDs as aliases, so they matched).
| */ | ||
| public EntitiesRequest transformFilter( | ||
| EntitiesRequest originalRequest, EntitiesRequestContext context) { | ||
| public EntitiesRequest process(EntitiesRequest originalRequest, EntitiesRequestContext context) { |
There was a problem hiding this comment.
Q: Any specific reason to rename the method as we have one more down transformFilter for TraceRequest? Are we planning to rename it as well in future?
There was a problem hiding this comment.
The reason I renamed it is this wasn't just transforming the filter, it was also modifying other parts of the request (selections), so the name "transformFilter" felt misleading. Since the class is called RequestPreProcessor, "process" seemed an apt name, but open to other suggestions.
In the meantime, will rename the trace version too.
There was a problem hiding this comment.
Trace version renamed.
|
|
||
| private Map<String, AttributeMetadata> getAttributeMetadataByResultName( | ||
| UpdateEntityRequest updateRequest, UpdateExecutionContext updateExecutionContext) { | ||
| return updateRequest.getSelectionList().stream() |
There was a problem hiding this comment.
Looks like AttributeMetadataUtil.remapAttributeMetadataByResultKey can be reused here?
AttributeMetadataUtil.remapAttributeMetadataByResultKey(updateRequest.getSelectionList(), updateExecutionContext.getAttributeMetadata())
There was a problem hiding this comment.
Thanks! I had implemented this multiple times before I realized it was identical and moved it to the shared util, must have missed fixing this one up.
| filterBuilder.setOperator(Operator.AND); | ||
| List<String> groupByColumns = groupByColumnList(originalRequest); | ||
| Map<String, Expression> groupBySelectionExpressionsByKey = | ||
| groupByExpressionByKey(originalRequest); |
There was a problem hiding this comment.
should we rename groupByExpressionByKey -> groupByExpressionByResultKey and groupBySelectionExpressionsByKey -> groupBySelectionExpressionsByResultKey?
or
groupByExpressionByResultName and groupBySelectionExpressionsByResultName?
There was a problem hiding this comment.
Sure, will use result name for consistency.
kotharironak
left a comment
There was a problem hiding this comment.
overall, lgtm. Have only a few minor comments which can be taken care of as follow-up if we are doing.
It seems to me that the test for alias changes are covered in the existing tests - attribute having an alias, not having - both in JSON files and in EnityServiceTest asserts for map change. So, scan one more time that if we haven't missed something.
Description
Replaced usages of column identifiers throughout with attribute expressions to support subpaths. Sorry for the large PR, difficult to add support piecemeal without breaking things. Requires QS release once hypertrace/query-service#132 is reviewed and merged..
Ref issue : hypertrace/hypertrace-ui#1099
Testing
Existing tests pass and verified E2E.