Skip to content

R2RML RefObjectMap fan-out: duplicate parent join keys should emit one ref per matching parent #1583

Closed

Description

@aaj3f

When an R2RML RefObjectMap's parent join key is non-unique (two parent rows share the join value but mint different subject IRIs), spec-correct behavior is to emit one referencing triple per matching parent (fan-out). Both the virtual query path (build_parent_lookup in fluree-db-query) and the twin builder (ParentIndexSet in fluree-db-r2rml) instead resolve the key to a single parent subject.

As of #1529's review-response commits this single pick is at least deterministic and self-documenting: both paths share a keep-min tie-break (lexicographically smallest parent subject — previously last-wins, which was run-to-run nondeterministic because the parent index consumes scan_table's buffer_unordered stream and I/O completion order chose the winner), fluree materialize declines such sources by default (--allow-duplicate-parent-keys to override), and an override-built twin records the distinct ambiguous-key count in its completion stamp.

The remaining work this issue tracks is the fan-out itself: a multimap parent index (key → all matching parent subjects) emitting one edge per parent on both paths, with the fused-aggregate admission gate's duplicate-key decline revisited accordingly (it currently declines the shape to avoid under-counting — correct until the fold can represent fan-out). Note the shapes interact: COUNT semantics over a fan-out join change row multiplicity, so corpus members with a non-unique-key fixture and native-oracle differentials should land in the same change. Since twins are rebuildable artifacts, re-materialization heals any override-built twin once this lands.

Context: bplatz's #1529 review (inline on graph.rs:330) + the adjudication record in the repo's audit working set (dup-key adjudication, 2026-07-31).

Activity

  1. aaj3f commented on Aug 3, 2026

    @aaj3f
    ContributorAuthor

    Cross-reference for whoever implements the fan-out here: the fused R2RML aggregate now admits a RefObjectMap (IRI) GROUP BY key (fluree-db-query/src/r2rml/fused_aggregate.rs, resolve_at_open, PR #1582 / commit 537a186). It folds on the referenced parent-subject IRI resolved once per parent row (deterministic keep-min on a duplicate parent join key, byte-identical to build_parent_lookup), which is correct only while a duplicate parent key resolves to a single ref — exactly the behavior this issue changes.

    When RefObjectMap fan-out lands (one ref per matching parent), group multiplicity changes, so the fused group-key admission and the generic path must flip in the same change or the native-oracle differential will catch the divergence. There is a comment at the admission site pointing back here; please revisit it as part of the fan-out work rather than discovering it via a failing differential.

  2. added
    P1
    area:iceberg
    on Aug 25, 2026
  3. aaj3f commented on Nov 2, 2026

    @aaj3f
    ContributorAuthor

    One more data point for this one: the SQL graph-source lane lowers a referencing object map to a real join (fluree-db-query/src/r2rml/sql_lane/lower.rs:2351-2380), so it already fans out one ref per matching parent row. The same mapping over an Iceberg source goes through keep-min (fluree-db-r2rml/src/materialize/graph.rs:241-266, used at fluree-db-query/src/r2rml/operator.rs:2848) and keeps only the smallest parent subject. So today the two lanes return different answers for the same mapping, which may be worth weighing in this issue's priority. The set-semantics side of the same R2RML §11 question is now #2238.

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:iceberg

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions