Skip to content

Display-profile rendering: compact Binding::Iri like stored/stamped IRIs (W3C surfaces settled by #1630) #1496

Open

Description

@aaj3f

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's PREFIX/@context declarations (via compact_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 the Binding::Iri arm of the formatter is written raw (fluree-db-api/src/format/sparql.rs:333 streaming, :487 DOM).

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

  1. Provenance consistency — should the same IRI value render identically regardless of provenance? If yes, the fix is to route Binding::Iri through compact_id_iri too (unconditional compaction), making constructed/federated/GRAPH/search IRIs compact like stored ones.
  2. Spec conformance — SPARQL 1.1 Query Results JSON serializes an iri binding 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 compacting uri bindings 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), so compact_id_iri is 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.rs expand_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

  1. aaj3f commented on Jul 14, 2026

    @aaj3f
    ContributorAuthor

    @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)

  2. aaj3f commented on Aug 25, 2026

    @aaj3f
    ContributorAuthor

    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 Sid and stamped IriMatch bindings compact while Binding::Iri (constructed IRI()/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 compact Binding::Iri uniformly (route the two sparql.rs arms through render_id_iri), and should F9's gate then dissolve into that? The divergent set has also been shrinking on its own — BM25/vector hits emit IriMatch when encodable, and #1641 (in flight) stamps cross-ledger SERVICE rows.

    Retitling to: "Display-profile rendering: compact Binding::Iri like 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.

  3. changed the title [-]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)[/+] on Aug 25, 2026
  4. added
    P3
    area:query
    on Aug 25, 2026
  5. added
    breaking-change
    on Nov 14, 2026
  6. added this to the 5.0.0 milestone on Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3area:querybreaking-change

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions