Repository navigation
Graph sources: a crawl keeps its ORDER BY, and a fused scan stays above an OPTIONAL - #2199
Conversation
…the page A subgraph crawl over a graph source runs as one flat scan regrouped by subject, and `build_flat_query` carried the WHERE, the projection and a triple LIMIT but not the ORDER BY. The page came back in scan order, and under an OFFSET it held the wrong subjects: `orderBy ?score, limit 3, offset 1` answered persons 2, 3, 4 where a native ledger answers 3, 2, 1. The flat query now carries the ORDER BY with the subject appended as the last key. Grouping assembles subjects in first-seen order and the triple LIMIT cuts the sorted rows, so both see the solution order; the subject tie-break keeps each subject's rows contiguous within one key, so tied subjects cannot interleave and the budget still covers whole subjects. The same rewrite carries no GROUP BY or HAVING either, so a crawl that asks for them is refused with the typed R2RML error, as a top-level `values` already is. Tests: every projection shape against a native twin of the fixture; the refusal; and the SPARQL side, where the shape that picks a page by ORDER BY is a CONSTRUCT (correct already) and DESCRIBE is refused on a graph source.
…TIONAL
The rewrite restores written order around an OPTIONAL by each pattern's
input slot, but three fusions placed the merged scan at the slot of the
scan that absorbed the other: a class into a star or into a crawl
wildcard, and W4-1b's constant-object constraint into the wildcard. When
the absorbed pattern was written above the OPTIONAL and the absorbing one
below, the constraint sank under the OPTIONAL, which then ran over an
empty seed and dropped every subject it did not match:
?s a ex:Person OPTIONAL { ?s ex:score ?x } ?s ?p ?o
answered no rows when no Person had a score, on SPARQL and JSON-LD, and
the browse crawl `{?s a C} OPTIONAL {?s P ?sort}` lost every row whose
column is null. The same misplacement ran the OPTIONALs uncorrelated and
the fused scan as a correlated scan over all of their rows: a crawl with
four OPTIONALs and LIMIT 25 took 198 s over 400k rows.
A fused scan now takes its earliest constituent's slot. A later
constituent rises to it only if no OPTIONAL in between reads a variable
it binds — the #1924 rule, now one helper shared by all four sites;
otherwise the fusion is refused and the patterns keep their own slots.
… pass `R2rmlScanOperator` joined its child one batch at a time, and each batch started a pass over the whole produced side, so a correlated scan under a large child did a table's worth of work per thousand child rows. With nothing to budget it, every row of the child is read: an ORDER BY crawl (the wildcard under a full class scan) or a correlated OPTIONAL over a class went quadratic, 2.4 s at 40k rows and 7.8 s at 80k. The scan now pulls its child in windows sized by the shared `FlushSchedule`, as the OPTIONAL seed and the batched join already do: budget-sized first under a LIMIT, growing from there, and otherwise one materialize window, the resident footprint a pass already accepts. The OPTIONAL's coalescing loop moves to `operator::flush::pull_window` so both lanes use one implementation. Warm runs over a local table shaped like the live `big` (40k / 80k rows): the ORDER BY crawl 2401 → 194 ms / 7805 → 666 ms; the same with an OPTIONAL sort key 925 → 298 / 3212 → 1009 ms; a flat OPTIONAL over the class 765 → 118 / 4292 → 486 ms. LIMIT shapes are unchanged within noise (minimum of 12 interleaved runs each way). `FLUREE_R2RML_CHILD_WINDOW=0` restores one pass per child batch.
A crawl whose WHERE puts a property beside `@type` (`{?s a C, p ?v}`)
fuses the class into the `p` star, and only the star. The crawl's
injected `?s ?p ?o` then carries no class, no hint and no bound subject,
so it resolves every TriplesMap. When the star's subjects are few, as
under a FILTER or for a small class, the wildcard's LIMIT budget is never
met and it streams every other table looking for subjects their templates
cannot produce: on a lake with a 5-row and a 2M-row table, a filtered
crawl of the small class read the whole large table and took over 20 s.
An ORDER BY crawl, which has no budget, read every table in full. A
class crawl with no property, and a crawl of one IRI, never hit this:
the class fuses into the wildcard, or the IRI prunes the maps.
When a class fuses into a star, a wildcard on the same subject is now
hinted to the class's maps, gated on every other map's subject template
being disjoint from the class's. The wildcard's rows survive only by
joining the star's subjects, which only the class's maps produce, so the
prune is resolution-only, as PR-3 (b') is for stars; no row changes. A
vertical partition (another map sharing the template) keeps it unhinted.
The D7 estimate that orders a pruning-key-less wildcard last, so it runs
as the LIMIT-budgeted outer scan, no longer counts the hint as a key: it
narrows which maps resolve, not the rows read, and a hinted wildcard
taking the default estimate could become the driving full scan.
Tests: the crawl over a small and a large table, filtered and with an
ORDER BY, reads the small table twice (star and wildcard) and the large
one never; rewrite tests for the hint and its vertical-partition refusal;
a planner test that the hinted wildcard still orders last.
The rewrite's written-order rules knew only OPTIONAL, at both places: the
variables a rising scan is checked against, and the gate on the restore.
The planner treats MINUS as positional too: what is written before it is
its left side. Two consequences:
- With an OPTIONAL in the scope, a fusion lifted the wildcard, a star or
a folded constraint above a MINUS that reads one of its variables. The
MINUS then needed that variable to agree too and removed too little:
`?s a ex:Person . MINUS { ?s ex:name ?o } OPTIONAL { … } ?s ?p ?o`
answered 5 rows where Jena ARQ and Oxigraph answer 0, on SPARQL and
JSON-LD.
- With a MINUS and no OPTIONAL, the restore never ran, so the grouped
stars and classes, emitted after the loop, ran below the MINUS and it
removed nothing (pre-existing on main).
A MINUS now counts as a barrier for the rise and gates the restore. The
rise past it is sound exactly when it reads none of the riser's non-subject
variables, the OPTIONAL argument, since the subject is already on its left.
The helper becomes `lifts_past_barrier` and its list `barrier_vars`, and
`star_member_subject`'s doc comment, spliced above the helper, is back on
its function.
Tests: every shape over the split mapping and a native twin holding the
same triples, on both surfaces, against the counts Jena ARQ and Oxigraph
give. They include the review's P3 and P3b verbatim, `?s a ex:Person .
BIND("k" AS ?k) MINUS { ?s ex:name "alice" } ?s ex:name ?n` with and
without a trailing OPTIONAL: 4 rows, where the graph source answered 5.
The same with the BIND written first answers 5, as its MINUS removes
nothing. Native Fluree answers every shape correctly; there is no native
planner bug. The apparent one came from comparing two different queries.
Each pass that reorders a group's patterns kept its own list of the ones whose position matters, and each list drifted narrower than the planner's: #1924, #1690, the R2RML rewrite's OPTIONAL-only restore (4ccbf1c), and its fusions lifting a scan past a MINUS. Every time the result was silent wrong rows around a left join or an anti-join. `Pattern::order_role` now answers it once, as an exhaustive match, so a new kind of pattern is a decision made in one place: `LeftJoin` (OPTIONAL), `AntiJoin` (MINUS), `GroupFilter` (FILTER), `GroupTest` (EXISTS, NOT EXISTS) or `Join`. `is_positional` is the left-join and anti-join pair. The planner's two consumers read it with exactly the sets they had: `left_join_order_barriers` anchors on `LeftJoin` and never makes a group filter or test the earlier side, and `reorder_patterns_with_seed` defers `AntiJoin` and `GroupTest` behind the patterns written before them. Plans do not change. The R2RML rewrite's rise check and restore gate read `is_positional`, the set the previous commit gave them.
`pull_window` appends a source's batches column by column, assuming every batch shares the first one's schema, which is the engine's convention. A batch in another variable order would have landed its values under the wrong variables. It now returns an `Internal` error instead, as the SQL lane's fallback check does. That is one slice compare per batch, in the OPTIONAL seed and the correlated R2RML scan alike.
The kill switch for the correlated scan's child window is in the operations table beside the other R2RML scan switches and in the virtual-dataset switch inventory. `FLUREE_R2RML_MATERIALIZE_WINDOW_ROWS` now also says it caps how many input rows a correlated scan holds per pass, which an operator sizing memory needs to know.
bplatz
left a comment
There was a problem hiding this comment.
Approving, with a little feedback.
Follow-up issues. The four items left out at the end of the body each want an issue, linked here as Follow-up: #N (per CLAUDE.md). The one I'd file first is the crawl rewrite still dropping reasoning and opts: it's the same class as fix #1, and with max-fuel among them a graph-source crawl runs without its fuel limit, on the path the Data tab browses with.
A note for the body. Without a row budget, the child window is a fixed MATERIALIZE_WINDOW_ROWS (512K), so a consumer that stops early without pushing a budget (EXISTS, ASK, a LIMIT above a FILTER) now gathers up to that many child rows before its first table pass, where it used to gather one batch. Worst case that's about one extra pass over the child side, against the quadratic it removes, so I think it's the right trade; worth saying so.
Checked and sound:
OrderRolegives the planner exactly the sets it had, so native plans don't change, and the exhaustive match makes a new pattern kind a decision.lifts_past_barrier: the fused scan sits at the earliest slot, where the subject is bound, and a later constituent rises only past OPTIONALs/MINUSes that read none of its other variables, which is when the left join and anti-join commute. Class-only scans and constant-object members bind only the subject, so they can always rise.- The D7 change reaches only the new crawl-wildcard hints: every other
class_prune_hintis set on a star, which thepredicate_varcheck excludes. - The wildcard class hint is gated on template-disjointness, and the wildcard's rows survive only by joining the star's subjects, so it narrows resolution without changing rows.
- The windowed join does the same total partial-row and cross work; under a LIMIT the first window is clamped to at least
MIN_FLUSH(the old batch was 1,000), and a mismatched schema is refused rather than appended by index. - The
?stie-break keeps a subject's rows contiguous under the triple budget. - Twins against a native ledger with ARQ/Oxigraph-derived counts, and a mutation per fix.
| // Same class as C1: `build_flat_query` carries no GROUP BY / HAVING, so a | ||
| // HAVING would be dropped and the crawl would answer subjects whose groups it | ||
| // rejects. Refuse rather than answer wrongly. | ||
| if ["groupBy", "group-by", "having"] |
There was a problem hiding this comment.
This refusal (and the existing top-level values one just above it) is a 400 a graph source now gives that a native ledger doesn't. docs/graph-sources/overview.md has a "Query Patterns a Graph Source Cannot Evaluate" list for exactly these; a line there for the crawl's groupBy / having / values would keep that list complete.
There was a problem hiding this comment.
Done in 0b3668ec6: "Query Patterns a Graph Source Cannot Evaluate" now lists the crawl's values, groupBy and having, each with its workaround — and the new depth refusal goes in the same list.
"Query Patterns a Graph Source Cannot Evaluate" listed the patterns a graph source refuses that a native ledger answers, but not the three a JSON-LD subgraph selection refuses: a top-level `values`, `groupBy` and `having`. Each is a 400 `err:r2rml/UnsupportedPattern` from the crawl rewrite, which has no place for them and would otherwise drop them. The section now names all three, with the workaround each refusal gives, and says a flat `select` takes them as usual.
A subgraph crawl over a graph source runs a rewritten flat query, and `build_flat_query` (and the constant-IRI expansion beside it) built that query from a list of the keys it kept: `@context`, `select`, `where`, `orderBy`, `limit`. Every other key was dropped, `opts` and the reasoning keys among them. So a crawl ran with no fuel limit, on the path a browse screen pages with, and ignored `reasoning`, `rules`, `ontology`, `reasoningBudget` and `reasoningTime`. `opts` also carries the parse switches (`strictCompactIri`, `objectVarParsing`, `includeSystemFacts`, `unionDefaultGraph`) that change how the crawl's own WHERE reads, and a `context` written without the `@` was dropped too. Same class as the dropped `orderBy`. The flat query now starts from the crawl's query and removes the keys the rewrite owns: the projection and query form, `where`, `limit`, `offset`, `orderBy`, the refused `values` / `groupBy` / `having`, and `depth`. It also removes the dataset keys (`from`, `ledger`, `fromNamed`, `to`, at the top level and in `opts`), which the caller already resolved into the view and which a view refuses as a cross-ledger `from`. Listing what is removed rather than what is kept means an option added later reaches the crawl without a change here. A tracked request's own fuel limit (the builder's `tracking`, which the server fills from its fuel header) never reached the crawl either: the two tracked terminals called it without one. They now pass it, and it replaces the body's limit as on every other tracked query, including when it names none. The crawl still reports no fuel, time or policy stats. Tests: the carried and removed keys and the override, as units; over the in-crate mock, a 2,000-row crawl failing past a 1.1 fuel limit in either spelling and succeeding under a generous one, the constant-IRI expansion refusing a sub-floor limit, the override holding and lifting the body's, and an RDFS crawl with an inline ontology answering the subclass's instances. Over the local Iceberg fixture, the body and the override limits on the connection and graph terminals, plain and tracked, and an unknown reasoning mode refused on a crawl as on a flat query. SPARQL has no subgraph crawl, so these have no SPARQL twin.
A subgraph crawl over a graph source refuses an `offset` past 10,000 subjects, since each page reads every subject before it again. The refusal was `ApiError::query`, which is an internal error: a 500 for a request the caller has to change. It is now the typed `err:r2rml/UnsupportedPattern` 400 the crawl's other refusals answer with, and the message says what the ceiling is and why. The graph-source overview lists it beside `values`, `groupBy` and `having`.
On a native ledger, `depth` expands each reference in a subgraph selection into the referenced node's own properties, that many levels down. The graph-source crawl renders a reference as its `@id` and expands none, and it dropped `depth` from the flat query it runs, so a crawl asking for `depth: 2` answered as `depth: 0` with a 200. A positive `depth` on a selection that reads properties (`["*"]` or a property list, with a variable or a constant-IRI root) is now refused with the same `err:r2rml/UnsupportedPattern` 400 as `values`, `groupBy` and `having`, naming the workaround. `["@id"]` and `["@type"]` read no reference, so any depth answers the same there and they still answer. A `depth` that is not a non-negative integer is refused as native refuses it (400), where the crawl used to ignore it. The graph-source overview lists the refusal.
The two tracked terminals answer a subgraph crawl over a graph source before their normal dispatch, and the crawl ran its flat query on the untracked path: it enforced the fuel limit, but the response carried no `fuel`, `time` or `policy`, where every other tracked query reports them, and a crawl that ran past its limit reported nothing it spent. The terminals now build the request's tracker the way the tracked query paths do (`tracked_query_tracker`: the override, else the body's `opts.meta` / `max-fuel`, else all tracking) and hand it to the crawl. The crawl's flat query records into it, through a new `query_view_with_r2rml_tracker` that the untracked `query_view_with_r2rml_options` now delegates to with no tracker, and the terminals report its tally on success and on error. The fuel limit now comes from that tracker, so the step that rewrote the flat query's `opts` from the override (`apply_fuel_override`) is gone. Fuel counts the flat query's work; grouping its rows into documents is not charged. Tests: over the in-crate mock, a tracked crawl's tally has fuel past the floor and a time, on the variable-subject crawl and the constant-IRI one, and the tracker's limit holds and replaces the body's. Over the local Iceberg fixture, the tracked connection and graph terminals report fuel and time on a crawl, and fuel on one refused past its limit.
The crawl module's doc and `maybe_expand_crawl`'s named one application's screen as the reason the crawl exists. They now describe it generically, as a browse screen listing a source's instances.
|
Thanks @bplatz. On the left-out items: the crawl dropping
The other three now have issues: Follow-up: #2222 (nullable OPTIONAL star member), #2223 (soft row hint for DISTINCT + LIMIT), #2224 (crawl parity: subject dedup and the always-emitted |
…s-from-manifests Brings in per-source storage identities (#2196) and the graph-source crawl fixes (#2199). The manifest-list totals cache is keyed by the manifest-list location qualified by the `StorageScope` of the storage plan that read it, as `table_metadata` and `scan_files` already are, so a total read under one identity is never served to another. - cache.rs: the totals accessors take the scope and key by `scope.qualify(location)`. - r2rml.rs: the three totals helpers take the scope; the /info read decides its storage with `catalog_read_plan` and builds it with `catalog_read_storage(&plan, &grant)`, the query path's decision. - iceberg_catalog.rs: `preview_iceberg_table_in` takes the identity context and the cache; `preview_storage_plan` is split out of `build_preview_storage` so the Schema-tier preview keys its totals by the plan's scope before building anything. The Stats-tier callers in iceberg_generate.rs and iceberg_validate.rs pass no cache. - ledger_info.rs: the /info count takes a plan closure. The deadline bounds the plan as well as the read, because planning a Google identity resolves its secret and proves the identity, either of which can be a remote call. The plan is polled once before the deadline is consulted, so a plan that is ready at once (ambient, vended, or a warm Google identity behind a resolver that answers at once) still serves a warm count past the deadline. - it_iceberg_local_fs.rs: both sides' tests are kept.
…out-mapping Brings in per-source storage identities and the one graph-source input codec (#2196), and the graph-source crawl fixes (#2199). Every resolution keeps both PRs' behaviour; where #2196 still offered a way to register an Iceberg source without a mapping, this branch's rule (a source needs a mapping) wins: - `create_iceberg_graph_source` and `test_iceberg_connection` stay removed. #2196's Direct storage-policy check at registration (`refuse_direct_storage_the_policy_refuses`) is kept, on the one remaining surface. Its two tests register through `create_r2rml_graph_source` with a mapping. - `IcebergCreateConfig::from_connection_for` and `iceberg_create_from_json` take no `has_mapping` flag, and `CatalogModeError::MissingTable` stays removed: a catalog mode's tables come from its mapping. - `POST /iceberg/map` keeps `required_mapping` (refused in words before the codec runs) and the response's `connection_check`. The codec's `ROUTE_FIELDS` list request fields; `connection_check` is a response field, and this branch adds no request field. - The CLI keeps main's codec-built connection and this branch's required `--r2rml` and `Connection:` line; its tests name a mapping. - Python keeps main's builder-based connection and this branch's per-outcome warning, with the released "could not reach the catalog" wording for a catalog that did not answer. - error.rs, errors.md: both PRs' error codes and statuses. - The docs keep #2196's connection sections and this branch's mapping rule and `connection_check`.
Brings #2247, #2232, #2246, #2248, #2245, #2230, #2205, #2231, #2255, #2219, #2209, #2207, #2190, #2216, #2186, #2215, #2213, #2184, #2210, #2206, #2198, #2187, #2183, #2200, #2193, #2199, #2196 and #2145 into next. Resolutions: - Novelty: main's fact-state trim (a cutoff plus a bounded sweep) and the dictionary's coverage watermark sit on next's graph slots and per-graph OrdMaps. A commit's reification links count toward coverage. Planner stats from segment sums decline under annotations, whose link deltas only the walk counts, and otherwise carry the indexed link counts. - Stats-view identity: the index root's id reaches the snapshot through next's root decoder (`decode` takes the id, as `take_snapshot_metadata` does). `LedgerState::load_record` has a decoding-root form beside `load_decoding_root`. - Transact: #2184's parallel-relationship check runs in next's link cascade, counting the `rdf:reifies` links on the retracted edge that the transaction does not retract itself. Main's bundle `edge_reifiers` is dropped, and `subjects_with_prior_rows` and `enforce_single_target_reifiers` stay deleted. The upsert pre-check takes main's dictionary probe and bounded seek. - Query: geo search resolves the graph's POST tree once at open (pooled graphs keep their filter), an empty manifest when there is none. `branch_or_none` reads the dedicated branch, and the batched joins keep next's pooled lanes. The stats-view key hashes the root id. - Indexer: `apply_dict_novelty` and `compact_forward_streams` take the cycle's compaction budget, so the term dictionary keeps its reserved share. `Prefetched` holds `ContentBytes`. `relocalize_sorted_commit` rewrites next's 20-byte types records. - Disk cache: main's in-flight write registration, with an empty entry still read as crash debris that a write replaces. The process-wide eviction walk stays removed. - Graph import (#2232): fenced CAS and publishes, the seed carries the record's namespace and fence, 32-bit graph ids and next's loaders. An import into a graph of an existing ledger refuses triple terms and edge annotations: the splice merges no triple-term dictionary yet. - Iceberg: `create_iceberg_graph_source` goes with main (a source needs a mapping); the R2RML path keeps next's `model_instance`. - CLI: main's shared import flags without the leaflet flags; `graph import` routes through next's process-wide server routing, and `upload_source_import` serves next's `Destination`. Doc sources read a ledger through the command's open instance. - Tests: sibling ledger ids become distinct names, `genesis_ledger` is awaited, Cypher state dumps include each relationship's `rdf:reifies` link, and the graph-import arena test checks the refusal instead.
This came out of driving the BigQuery lake flow end to end against BigQuery. A lake graph's Data tab browses with a graph crawl, and over an R2RML/Iceberg graph source that crawl was returning the wrong page. Chasing that turned up a second, worse bug that's been on
mainfor a while and isn't specific to the crawl. Four commits, two correctness fixes and two perf fixes, best read in order, plus four more from a self-review pass (below).1. A crawl over a graph source lost its ORDER BY (
a5111f5b4).build_flat_query(fluree-db-api/src/graph_source/crawl.rs) rebuilds the crawl from select/where/limit and quietly droppedorderBy, andgroupBy/havingwith it. So the page came back in scan order, and with an OFFSET it held the wrong subjects, not just the right ones out of order: on the local people fixture, asc / limit 3 / offset 1 gave persons 2,3,4 where the native ledger gives 3,2,1. Live, sorting a 5-row table by price came back 4,2,5,3,1. It now carriesorderBywith?sappended as the tie-break, which also keeps a tied subject's rows contiguous so the triple budget never cuts one in half.groupBy/havingare refused with the typed R2RML error, the same way a top-levelvaluesalready is, rather than silently dropped. Native ledgers were already right.2. A fused scan could sink below an OPTIONAL and drop rows (
5569658f5), pre-existing on main, both surfaces. Three fusions influree-db-query/src/r2rml/rewrite.rs(class into the crawl wildcard, class into a star, and the W4-1b constant-constraint fold) put the merged scan at the absorbing scan's slot. The "restore written order around OPTIONAL" sort then moved a class written above an OPTIONAL below it, so the OPTIONAL ran over an empty seed and every subject it missed was dropped. With two disjoint maps over the people table,{?s a ex:Person} OPTIONAL {?s ex:score ?x}crawls to[](should be 5), and the SPARQLSELECT ?s ?p ?o WHERE { ?s a ex:Person OPTIONAL { ?s ex:score ?x } ?s ?p ?o }returns 0 rows (should be 10). The realistic trigger is a NULL column under an OPTIONAL: those rows just vanish. One rule now covers all four fusion sites (lifts_past_optional): a fused scan takes its earliest constituent's slot, and a later one may rise only past OPTIONALs that read none of its non-subject variables (this is #1924's rule, consolidated); otherwise the fusion is refused and the class keeps its prune hint. This changes query results on main, but only by returning rows that were wrongly dropped.3. A correlated scan re-read the whole table per child batch (
4f8f4ddaa).R2rmlScanOperatorstarted a full produced-side pass for every 1,000-row child batch, so any unbudgeted correlated scan was quadratic, which in practice meant any ordered crawl or flat OPTIONAL over a big class. It now joins a window of child rows per pass through the sharedFlushSchedule(budgeted under a LIMIT, one materialize window otherwise); the OPTIONAL's coalescing loop moved as-is intooperator/flush.rs::pull_window, so both lanes share it.FLUREE_R2RML_CHILD_WINDOW=0turns it off.4. A filtered crawl read every table in the mapping (
26e8cc22b). When the WHERE puts a property beside@type({?s a Amounts, id ?f0}), the class fuses into that star and is consumed there, so the crawl's injected?s ?p ?owildcard was left with no class and resolved to every triples map. On a two-table lake (a 5-row table beside a 2M-row one) a filtered crawl of the small table streamed all 2M rows of the other looking for subjects its disjoint template can't produce, which is the 20 s+ we saw live. Now, when a class fuses into a star, a standalone wildcard on the same subject gets that class as aclass_prune_hint, gated onwildcard_class_fusion_is_safe(every non-class map is template-disjoint). It's resolution-only, the same argument as PR-3 (b'), so no rows change; a vertical partition stays unhinted. D7's FULL_SCAN estimate no longer keys on the hint being absent, so the hinted wildcard still orders last as the budgeted outer scan. Pinned on a smallpeopletable beside a 2,000-rowordersone: the filtered crawl and an ORDER BY crawl with a property in its WHERE both assertordersis never scanned. This one didn't reproduce locally before, because the local mapping had a single table.After a self-review pass (adversarial, on our side, before asking for review), which found that #2's fix had a blind spot:
bb5045cf8: MINUS is positional too. The rise check and the written-order restore knew only OPTIONAL, so a fused scan could lift past a MINUS that reads it, and a scope with a MINUS but no OPTIONAL was never restored to written order. On the split mapping,?s a ex:Person . MINUS { ?s ex:name ?o } OPTIONAL { … } ?s ?p ?oreturned 5 rows where the spec and a native twin give 0 (main got it right only because its OPTIONAL bug happened to empty the result), and?s a ex:Person . BIND("k" AS ?k) MINUS { ?s ex:name "alice" } ?s ex:name ?nreturned 5 on both main and the PR where the spec and native give 4. Both now agree. The twin test runs nine shapes on both surfaces against the graph source and a native ledger holding the same triples, with the expected counts taken from Jena ARQ and Oxigraph run independently; native answers every one of them correctly.7ab9ef939: one place says which patterns are positional. This is the fourth time a reorder pass kept its own, shorter list of order-sensitive patterns (Planner hoists a triple above a preceding OPTIONAL that binds a shared variable, returning wrong rows #1924, VALUES after OPTIONAL cross-products instead of joining (silent wrong results) #1690,4ccbf1cd4, and the MINUS gap above), soPattern::order_role()is now an exhaustive match (OPTIONAL, MINUS, FILTER, EXISTS/NOT EXISTS, plain join) thatleft_join_order_barriers,reorder_patterns_with_seedand the R2RML rewrite all read. A new pattern kind won't compile until it has a role. The planner reads it with exactly the sets it had before, so native plans don't change.f206b4655: the coalesced window now refuses a batch whose schema differs from the first (anInternalerror, as the SQL lane does) instead of concatenating by column index on trust.2ecac0795:FLUREE_R2RML_CHILD_WINDOWis documented inconfiguration.mdandSWITCHES.md, and theMATERIALIZE_WINDOW_ROWSrows now say it also caps the child window.Measured on a local twin of the live 2M-row table, warm runs, on a box other sessions were loading heavily (so treat the speedups as lower bounds):
The ordered crawl's "before" was a wrong page in 35 ms; the right page now costs about what the flat ordered query does. LIMIT shapes are unchanged within noise (min of 12 interleaved runs each way at 80k).
Tests:
a_graph_source_crawl_answers_in_order_by_order(three projections against a native twin), itsgroup by/havingrefusal, a SPARQL CONSTRUCT twin,an_optional_keeps_the_class_written_above_it(crawl, constant crawl, class→star, flat wildcard and SPARQL), four rewrite unit tests and an operator pass-count test. Each fix was broken on purpose, and the tests went red (10 of 10).Left out here, each now an issue:
OPTIONAL { ?s p ?x }into a star as a nullable member (one scan instead of 1+N; extends the per-row star assumption, so it wants a decision).selectDistinct ?s … LIMIT nreads far more than it returns #2223 —selectDistinct ?s LIMIT 25stays 25–50× slower thanselect, because DISTINCT rightly swallows the LIMIT budget; a soft row-size hint could fix that without changing results.@idfor a predicate-list projection.[]when its classes are outside the default namespaces #2225 — reasoning over a graph source whose classes are outside the default namespaces answers[](pre-existing; found while testing the options fix below).Review round (2026-10-30). The crawl rewrite now carries every query option it doesn't own (
optsincl. max-fuel,reasoning,rules,ontology, the reasoning budgets,distinct) (f2065d617); a tracked crawl runs under the caller's tracker and reports fuel, time and policy (37f7f28de);depthother than 0 is refused with a 400 rather than quietly answered as 0 (175f1414f); an offset past the paging ceiling is a 400 (d7676622b); and the overview's list of refused patterns namesvalues,groupByandhaving(0b3668ec6).The child window, with no row budget. It's a fixed
MATERIALIZE_WINDOW_ROWS(512K), so a consumer that stops early without pushing a budget (EXISTS, ASK, a LIMIT above a FILTER) now gathers up to that many child rows before its first table pass, where it used to gather one batch. Worst case that's about one extra pass over the child side, against the quadratic it removes.Claude Code did the legwork on this one too: the repros, the rewrite archaeology, the measurements and the mutation checks. Happy to talk through any of it.