Fix aggregate count mapping when alias collides with traversal#49
Merged
Conversation
Root cause: irToAlgebra renames aggregate aliases that collide with traversal aliases (e.g. a1 → a1_agg) and updates resultMap, but not the projection. buildNestingDescriptor then fails to find the projection entry for the renamed alias, silently dropping the aggregate field. Fix: when a resultMap entry has no matching projection (renamed by irToAlgebra), create a flat field descriptor using the resultMap alias directly as the SPARQL variable name, with maxCount: 1. Adds unit test simulating the exact alias rename scenario. 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
Fixes
countNestedFriendsandcountLabelFuseki tests returningundefinedfor aggregate count values.Root cause
irToAlgebrarenames aggregate aliases that collide with traversal aliases (e.g.,a1→a1_agg) and updatesresultMap, but not theprojection. WhenbuildNestingDescriptorinresultMapping.tslooks up the projection byentry.alias(a1_agg), it finds nothing because the projection still hasa1. The aggregate field is silently dropped — no count value appears on the result row.Fix
When a
resultMapentry has no matching projection entry (indicating anirToAlgebrarename), create a flat field descriptor using theresultMapalias directly as the SPARQL variable name, withmaxCount: 1(aggregates always produce single scalar values).Test plan
a1, resultMap hasa1_agg, Fuseki bindings havea1_agg→ result correctly maps to count values (p1=2, p2=0)https://claude.ai/code/session_017mqanCkMvA1VU8MVD7hkA1