Skip to content

Recognize edge-only blank nodes in SPARQL results - #2668

Open
kmcginnes wants to merge 1 commit into
mainfrom
sparql-blank-node-neighbor-counts
Open

kmcginnes wants to merge 1 commit into
mainfrom
sparql-blank-node-neighbor-counts

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Summary

When a SPARQL node's neighbors include blank nodes that have no triples of their own, expanding the node made the neighbor counts request fail, because those blank nodes were not recognized as blank nodes.

User-facing: On SPARQL databases such as the Nobel Prize dataset, expanding a node with blank node neighbors (for example a laureate's death place) now loads neighbor counts for every neighbor, instead of failing with "Malformed SPARQL query".

A blank node that appears only as an edge endpoint got no vertex from the quad mapper. fetchNeighbors filled it in as a plain vertex, so it never entered the blank node map, and neighborCounts sent its label to the database as an IRI (<d31718…>), which strict endpoints reject for the whole batch.

 mapQuadToEntities(bindings)
   for each binding
     if edge binding
       add edge
+      for each blank node endpoint (subject or object)
+        add vertex draft { id, isBlankNode: true }, merged with any other draft
     else
       add vertex draft from the binding

Evidence

Before: expanding Nobel laureate 259 sent both count queries with <d31718c5856d46f9aa8963926f0fd13299> in VALUES, and the endpoint answered 400 "Malformed SPARQL query" to each.

After: new tests in the mapper, fetchNeighbors, and the SPARQL explorer fail without the fix and pass with it. The explorer test runs fetchNeighbors then neighborCounts and checks that no counts query contains the blank node label as <label> and that the blank node goes down the blank node path.

Verified live: expanded laureate 259 against the public Nobel Prize SPARQL endpoint through the dev server. All five SPARQL requests returned 200, the count queries listed only the five URI neighbors, and every URI neighbor showed its count.

Merge Danger

Door: two-way

Impact: small

Edge-only blank nodes are now treated like every other blank node, so they are no longer saved in the graph session, matching existing blank node behavior.

Related


🤖 Written by an AI agent on my behalf.

Layer: 1-sparql-blank-node-neighbor-counts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank nodes returned during expansion are not being recognized

1 participant