Skip to content

query: within-ledger FROM default-graph union should be a set-merge, not a bag #1469

Closed

Description

@aaj3f

Deferred from PR #1462 review (O6). Type: correctness / SPARQL §13.2 spec-conformance — NOT a mere optimization (the fix is perf-constrained, the issue is a conformance gap; tag it accordingly so it isn't triaged as an optional perf tweak). DatasetOperator::next_batch (fluree-db-query/src/eval/dataset_operator.rs:407-458) concatenates default-graph members without dedup. Per SPARQL §13.2 the default graph of a dataset is the RDF merge (set) of the FROM graphs, so FROM <g1> FROM <g1> should not double-emit and FROM <g1> FROM <g2> should count a shared (s,p,o) once (the graph component is stripped in the merge). Current behavior is a bag-union → duplicate rows. Inherited (cross-ledger hits it too); PR-G2 makes it one-line reachable within a single ledger.

Why deferred: perf-sensitive — a correct fix needs per-row dedup at (s,p,o) triple-identity across members (hash-set or sort-merge), adding cost + memory on the multi-FROM path; the common no-FROM/single-graph path is untouched.

Acceptance: FROM <g1> FROM <g1> = single copy; shared triples counted once; single-graph/no-FROM path byte-identical + within the perf budget.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions