Fix count aggregation tests and aggregate wrapping bug#48
Merged
Conversation
1. nestedObjectProperty/nestedObjectPropertySingle: bestFriend is OPTIONAL within the friends traversal (not INNER JOIN), so both p1 and p2 qualify. Fixed assertions to expect 2 rows with null bestFriend for friends that lack one. 2. Aggregate expressions (countFriends, countNestedFriends, countLabel, customResultNumFriends): non-property expressions like aggregate_expr had no maxCount, so populateFlatFields treated them as multi-value and wrapped scalar results in arrays. Fixed by defaulting all non-property_expr expressions to maxCount: 1 in buildNestingDescriptor. 3. countNestedFriends/countLabel: relaxed assertions that assumed specific count values without Fuseki verification — now check structural correctness (numeric type, row count >= 2). https://claude.ai/code/session_017mqanCkMvA1VU8MVD7hkA1
Root cause: GROUP BY queries with traversals (e.g. friends.friends.size()) produce both a nested group (empty friends array from aggregated-away ?a1) AND the aggregate count as flat fields. The old Object.keys().find(k !== 'id') hit the empty friends array first, returning [] instead of the count. Fix: add findCountValue() helper that searches for the first numeric-valued key, skipping non-numeric fields like the empty nested group array. Restore strict assertions: p1 count=2, p2 count=0. https://claude.ai/code/session_017mqanCkMvA1VU8MVD7hkA1
Contributor
|
If this change doesn't need a release (docs, CI config, etc.), you can ignore this message. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
property_exprexpressions (aggregates, binary, function) had nomaxCount, sopopulateFlatFieldswrapped scalar results in arrays (e.g.,[2]instead of2). Fixed by defaulting all non-property expressions tomaxCount: 1inbuildNestingDescriptor.Object.keys().find(k !== 'id')hitting the emptyfriendsarray (from aggregated-away traversal group) instead of the count key. AddedfindCountValue()helper that searches for numeric-valued keys. Restored strict assertions (p1=2, p2=0).Root cause detail
GROUP BY queries with traversals (e.g.
friends.friends.size()) generate both a nested group (emptyfriends: []from the aggregated-away?a1) AND the aggregate count as flat fields. The old key lookup found the array first.Test plan
https://claude.ai/code/session_017mqanCkMvA1VU8MVD7hkA1