Repository navigation
Description
Summary
While working on Iceberg/R2RML (virtual-dataset) pathway optimizations, we discovered that the native SPARQL-results-JSON formatter renders IRIs provenance-dependently:
- IRIs that come from stored data (
Binding::Sid) are compacted to CURIEs using the query'sPREFIX/@contextdeclarations (viacompact_id_sid → compact_id_iri). - IRIs that are constructed, federated, GRAPH-bound, or search-produced (
Binding::Iri) are rendered as full IRIs, even when a declared prefix matches, because theBinding::Iriarm of the formatter is written raw (fluree-db-api/src/format/sparql.rs:333streaming,:487DOM).
So two bindings with the identical IRI value can render differently based solely on their provenance. Example (a query declaring PREFIX edw: <http://ns.fluree.dev/edw#>): a stored edw:name predicate renders edw:name, but BIND(IRI("http://ns.fluree.dev/edw#name") AS ?p) renders http://ns.fluree.dev/edw#name.
As part of the virtual-dataset work we are aligning the virtual path to native's current internal model (scoped, so we do not change native output). This issue raises the broader question: should both native and virtual change — and to what? It is a product/spec decision, deliberately deferred out of the perf branches.
(a) Where native produces Binding::Iri (the provenance-dependent, currently-raw sites)
All five are native-reachable (verified by workspace enumeration):
| site | trigger | reachable via |
|---|---|---|
fluree-db-query/src/eval/value.rs:522 |
ComparableValue::Iri not encodable to a SID (code comment names UUID, IRI()) |
BIND(IRI("…")) / UUID() / constructed IRIs |
fluree-db-query/src/sparql_results.rs:84,88 (via fluree-db-api/src/remote_service.rs:153) |
remote SPARQL-Results uri/bnode term |
SERVICE <…> { } federation |
fluree-db-query/src/graph.rs:343,440 (via Binding::iri()) |
the ?g graph-variable value |
GRAPH ?g { } projection |
fluree-db-query/src/bm25/operator.rs:615 |
full-text hit IRI not encodable to a SID | BM25 search (cross-ledger/unencodable hit) |
fluree-db-query/src/vector/operator.rs:350 |
vector hit IRI not encodable to a SID | vector search (same) |
The compaction mechanism itself is @context/PREFIX-driven only: ContextCompactor::compact_id (fluree-graph-json-ld/src/compact.rs:60) keys exclusively on the parsed context and never consults the namespace-code map. That is why stored IRIs whose prefix is not declared (e.g. rdf:type, and reference IRIs in an undeclared namespace) also render full today — compaction tracks the query's declared prefixes, nothing else.
(b) The decision has two independent dimensions
- Provenance consistency — should the same IRI value render identically regardless of provenance? If yes, the fix is to route
Binding::Irithroughcompact_id_iritoo (unconditional compaction), making constructed/federated/GRAPH/search IRIs compact like stored ones. - Spec conformance — SPARQL 1.1 Query Results JSON serializes an
iribinding as its full string value ({"type":"uri","value":"http://…"}); there is no CURIE form in the spec. On a strict reading, the CURIE-compaction native already does is the non-conforming behavior, and the conformant move would be to stop compactinguribindings at all (native included).
These point in opposite directions (compact everything vs compact nothing). Picking one is a product/compat call — changing native's long-standing output affects existing consumers either way.
(c) The change-space is unconstrained by existing test gates (measured)
- W3C SPARQL suite is immune. The W3C runner formats actual results with an empty
ParsedContext(testsuite-sparql/src/query_handler.rs:256/258, 308/310, 392/395), socompact_id_iriis a no-op there (no prefixes to match) regardless of which direction is chosen. Independently, the harness expands any compact IRI back to absolute form (result_format.rsexpand_id/expand_vocab) and compares isomorphic RdfTerms (result_comparison.rs), so even compacted output would compare equal. - No corpus/regression query exercises this. The virtual-dataset corpus has no query using
GRAPH ?g/SERVICE/BIND(IRI|UUID).
So whichever direction the team picks is not blocked by current gates — the decision can be made on product/compat grounds.
(d) Context
Root-cause + mechanism analysis (and the virtual-side alignment): docs/audit/2026-07-virtual-dataset-perf/16-pr-f9-curie-alignment.md (on the virtual-dataset perf branch). Found during the F9 virtual CURIE-alignment work; tracked there as the deferred native-side question.
Activity
aaj3f commentedon Jul 14, 2026
@bplatz @zonotope -- nothing is currently broken with the above issue being true in the code, but I did have to engineer a workaround for the virtual/r2rml pathways to ensure they support the same behavior and can produce the identical query results that the native query pathway produces. It would be worth coming to a decision about the above and, once we do, ensure that both the native query path and the virtual dataset query path re-align to the pattern (that is, if it changes from its current behavior)
docs(audit): correct F9 root cause (dated addendum) + file F16 + cros…
aaj3f commentedon Aug 25, 2026
Narrowing this after a sweep re-verification at
47e96b7b6: one of the two dimensions this issue posed has since been decided in code. #1630 (merged 8/11) made all W3C result formats (sparql-results+json, XML, CSV, TSV) emit absolute IRIs — so on those surfaces the provenance divergence documented here is simply gone, resolved in the spec-conformant direction.The remainder is display-profile-only: under the CLI's compacting profile, stored
Sidand stampedIriMatchbindings compact whileBinding::Iri(constructedIRI()/UUID(), remote-SERVICE terms,GRAPH ?g, unencodable search hits) renders raw — except graph-source results in sparql_json, which F9 special-cased. The open question shrinks to: should the display profile compactBinding::Iriuniformly (route the twosparql.rsarms throughrender_id_iri), and should F9's gate then dissolve into that? The divergent set has also been shrinking on its own — BM25/vector hits emitIriMatchwhen encodable, and #1641 (in flight) stamps cross-ledger SERVICE rows.Retitling to: "Display-profile rendering: compact
Binding::Irilike stored/stamped IRIs (W3C surfaces settled by #1630)". One note for the eventual fix, correcting my original caution: at format time this is purely cosmetic — join/DISTINCT/GROUP BY identity is untouched, since that caution applied to changing binding representation, not the formatter arm.[-]SPARQL-results-JSON renders IRIs provenance-dependently (stored Sids compact per query PREFIX; constructed/federated/GRAPH/search IRIs render raw)[/-][+]Display-profile rendering: compact Binding::Iri like stored/stamped IRIs (W3C surfaces settled by #1630)[/+]