Skip to content

next: an annotation query across two ledgers returns no rows #2444

Open

Description

@bplatz

An annotation query whose FROM names two ledgers returns no rows on next. On main it returns the RDF merge of both ledgers' annotated edges.

SELECT ?s ?role FROM <ledger-a> FROM <ledger-b>
WHERE { ?s ex:worksFor ex:acme {| ex:role ?role |} }

The case is pinned by it_union_annotation_chain, added to main in #2214 (1c756de51, "an annotated edge two graphs of a union hold is one solution"). It came to next with the merge of main and passes on main. On next the same-ledger cases of that test pass and the two-ledger cases are skipped until this is fixed.

This blocks merging next into main: the query works on main today.

Why it fails on next

  • main stores an annotation as plain triples on a reifier (f:reifiesSubject and so on). A cross-ledger query converts each member's subjects into IriMatch (stamp_provenance), so the edge, the reifier and the annotation body join by IRI.
  • next stores it as an RDF 1.2 triple-term link (?r rdf:reifies <<( s p o )>>). The chain joins through TermComponentsOperator, which finds candidate triple terms in one store's triple-term dictionary, the primary ledger's. The other ledger's terms are never candidates, and the IDs inside a triple-term value are never converted to IriMatch. Nothing joins, so the answer is empty.
  • Before the merge, next ran a multi-source default graph one source at a time. That was wrong too: it returned an annotated edge both ledgers hold twice, and after indexing it paired roles with the wrong subjects ("bob Manager" twice, "carol Intern" once against "bob Manager" once and "carol Intern" twice). The merge brought main's build-once chain over a union, which works for graphs of one ledger and returns nothing across ledgers.

A possible fix

  1. Route an annotation chain over a dataset that spans ledgers to the per-source path in DefaultGraphSourceOperator, so each ledger reads its own dictionary and its IDs agree. Graphs of one ledger keep the build-once path.
  2. Deduplicate the per-source rows across ledgers on the chain's full row, the reifier included. An edge and annotation both ledgers hold is one solution, and two annotations of one edge stay two.
  3. Find and fix the mispairing the per-source path shows after indexing (cause not yet known).

The alternative, making TermComponentsOperator and the cross-ledger conversion understand triple terms across stores, looks larger.

Re-enable the two-ledger cases in fluree-db-api/tests/it_union_annotation_chain.rs when fixed.

Activity

  1. added
    bug
    P1
    area:query
    on Nov 18, 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

    P1area:querybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions