Repository navigation
feat(delta): Delta Lake graph sources on local, S3, ADLS Gen2 and OneLake; reqwest 0.13 (outbound TLS trusts the OS certificate store) - #1899
Conversation
8f5274c to
63c1180
Compare
aaj3f
left a comment
There was a problem hiding this comment.
@bplatz this all makes sense and the work seems good to me. This is not an objection, because in many ways I think it makes sense, but just want to note that this adds (in fluree-db-delta/src/prune.rs + datafile.rs) a second parquet predicate evaluator to the preexisting fluree-db-iceberg's scan/pruning.rs + arrow_reader.rs. Making them share modules would be non-trivial (and maybe wouldn't be clean & performant, I'm not sure), so perhaps that's a permanent keep, but I am nervous a little that they are going to drift over time as nothing coheres them together at this point. There's also some performance notes I include below on per-file scan worker threads--I imagine that one you may want to address pre-merge.
This is carefully built, @bplatz — Delta on Kernel, plugged into the same R2RML provider, mapping registration, pushdown contract, @snapshot:/@time: pin and policy gate as Iceberg and SQL, rather than a parallel stack, and the de-duplication of mapping registration and scan-filter construction along the way is a real improvement. The commit bodies are excellent, and the differential test plus routing stamps are the right shape for a pushdown lane. Two things I think need to land before merge, both small. First, the scan's per-file workers park threads of the server's blocking pool on consumer backpressure (fluree-db-delta/src/table.rs:450/473), so concurrent Delta load can starve — and in the worst case circular-wait against — file-backed storage reads that share that pool; entering the scan's own runtime before the spawn (one line, which I tried against a probe) fixes it. Second, row-group pruning trusts legacy signed-order string statistics (prune.rs:85), which silently drops matching rows on Parquet files from pre-1.10 parquet-mr writers, e.g. a CONVERT TO DELTA of an old Spark/Hive dataset; one is_min_max_deprecated() check fixes it.
Two process notes, both calls for you rather than asks. The branch carries workspace-wide changes that release notes built from this PR's title won't surface — reqwest 0.13 (outbound TLS now trusts the OS store instead of bundled roots; documented, but an operator-visible change), OpenTelemetry 0.32, Arrow/Parquet 58 in the Iceberg decode path — plus the four shared fixes you offered to split, one of which (SPARQL POST /query with FROM <graph source> returning no rows on main) is a silent-wrong-result bug that probably shouldn't wait behind a three-PR stack. I'd lean toward splitting the fixes and the dependency moves into their own PR(s) against main, but that's your call. And now that Iceberg and Delta each have their own Parquet pruner, footer cache and row filter with different type rules (the string-statistics issue above is one rule the Iceberg side never needed because it doesn't prune strings), it may be worth deciding where Parquet-level pruning should live; that's a genuinely large convergence, so I'd treat it as a follow-up that needs a decision rather than something for this PR.
Adherence to repo commitments:
- Patterns/abstractions: ✔ extends
FlureeR2rmlProvider/R2rmlTableProvider,register_r2rml_mapping,ScanFilter,SourceTime, the policy gate and the local-root allowlist;⚠️ a second Parquet pruner/row filter alongside Iceberg's. - Performance (speed first, memory second):
⚠️ native engine untouched (no degradation risk there); graph-source paths faster per the PR's numbers (no bench covers R2RML/Iceberg/Delta); blocking-pool parking under concurrent load (see the blocking comment ontable.rs); memory bounded by batch size, channel depths and the two process-wide budgets. - Testing:
⚠️ strong reader, pruning, differential, HTTP and CLI tests, all running in CI on this head (58 by name,required-featureswired); nothing pins Kernel's protocol-feature refusal, and the legacy-statistics case is untested (see the blocking comment onprune.rs); cloud backends are covered by one ignored Entra test and by-hand live runs only. - Conventions: ✔ multi-line bodies with rationale throughout, clippy/fmt green in CI, docs updated (Delta guide, CLI, endpoints, configuration, time-travel);
⚠️ misplaced doc comment inoperator.rs, and the PR title doesn't reflect the workspace-wide dependency changes.
Verified locally at branch HEAD: cargo test -p fluree-db-delta (all pass, incl. the new reader/pruning/no_log_cache binaries); three mutation checks on load-bearing guards (deletion-vector decode-whole, future-version refusal, log-answered count vs deletion vectors), each caught; throwaway probes for blocking-pool holding (an unconsumed scan holds a 2-thread pool; the one-line fix releases it), protocol-feature refusal (Kernel refuses, at scan planning rather than snapshot) and legacy string statistics (row group wrongly ruled out; the one-line fix keeps it); CI run 35520130781 on 9712e0c3c green with the Delta suites present by name.
Just be sure to get the two blocking fixes in before this merges — and since the base is feat/time-spec-time-tag, it'll need retargeting to main as #1896/#1897 land. Happy to talk through any of these.
| queue.clone(), | ||
| tx.clone(), | ||
| ); | ||
| tokio::task::spawn_blocking(move || loop { |
There was a problem hiding this comment.
Blocking (performance under concurrent load) — The Delta scan parks threads of the server's blocking pool for the length of the scan, waiting on storage and on the consumer.
(Also table.rs:450, :669, :690.)
scan() starts its planner and then up to scan_concurrency(files) workers — min(cores, 32, files) by default — with tokio::task::spawn_blocking, which runs them on the caller's runtime (the server's). Each worker keeps its thread for its whole share of the file queue and spends most of that time parked: in batches.blocking_recv() while the owned executor fetches and decodes, and in tx.blocking_send(...) whenever the depth-4 channel is full because the R2RML operator hasn't pulled yet. So a scan holds its server blocking threads for the whole scan — waiting on storage or on the consumer, not doing work — and a consumer that stops pulling holds them indefinitely. The Iceberg decode uses spawn_blocking too, but each of those tasks is bounded by its own I/O and decode and returns a Vec — it never waits on the consumer.
Why it matters: Tokio caps the blocking pool at 512 threads by default (neither fluree-db-server/src/main.rs's #[tokio::main] nor the CLI's runtime builder in fluree-db-cli/src/main.rs:207 raises it), and file-backed ledger storage reads go through tokio::fs on that same pool (fluree-db-core/src/storage/file.rs:1168). On a 16-core server, 32 concurrent Delta queries over tables of 16+ files hold all 512, and native queries' index reads queue behind them. In the worst case it circular-waits: a query that joins a Delta source to a file-backed ledger needs a blocking thread for a tokio::fs::read before it can pull its next Delta batch, while the Delta workers holding every thread are waiting for it to pull.
I checked this with a throwaway test: on a caller runtime with max_blocking_threads(2), a scan of the six-file partitioned fixture that nobody pulls from leaves an unrelated spawn_blocking(|| 1) unable to run for 3 s; dropping the stream frees it.
The owned runtime is already there, so the fix is small. One caveat first: Kernel's TaskExecutor::spawn_blocking is tokio::task::spawn_blocking on the current runtime, so routing through it doesn't help. What does work is entering the owned runtime before the planner is spawned — the workers are spawned from the planner's thread, so they follow it onto the Delta runtime's blocking pool:
let _delta_runtime = self.table.executor.enter();
tokio::task::spawn_blocking(move || {With that one line the probe above passes and pruning/reader stay green. More fully, the worker loop could become an async task on the executor (decoded.recv().await, tx.send(batch).await) with the per-batch transform, deletion-vector split and row filter run inline (CPU over one 8,192-row batch), so nothing parks a thread at all.
|
|
||
| fn group_may_match(group: &RowGroupMetaData, leaf: usize, term: &Term) -> bool { | ||
| let chunk = group.column(leaf); | ||
| let Some(stats) = chunk.statistics() else { |
There was a problem hiding this comment.
Blocking (silent wrong results; narrow input class, one-line fix) — Row-group pruning trusts legacy signed-order string statistics.
group_may_match takes chunk.statistics() min/max at face value. parquet-rs fills those from the deprecated thrift min/max fields when min_value/max_value are absent (parquet-58.4.0/src/file/metadata/thrift/mod.rs:210-222) and only flags it through Statistics::is_min_max_deprecated(). Writers before PARQUET-686 (parquet-mr < 1.10 — Spark ≤ 2.3, older Hive and Impala) computed BYTE_ARRAY bounds in signed byte order, so for any UTF-8 value with a byte ≥ 0x80 the recorded "min"/"max" are not bounds under the unsigned order order() uses at prune.rs:268. The comment at prune.rs:233-235 ("never tighter") holds for modern writers only.
Concretely: a row group holding {"apple", "banana", "émile"} written by parquet-mr 1.8 records min = "émile", max = "banana". FILTER(?label = "apple") becomes within("émile", "apple", "banana"), 0xC3 > 'a', the row group is ruled out, and "apple" never reaches the engine — no error, just a missing row. The log's own statistics are unaffected (Kernel's file skipping is fine); only in-file pruning is. The input class is real: CONVERT TO DELTA is the documented way to turn an existing Parquet dataset into a Delta table in place, and it does not rewrite the files. I reproduced the exclusion with a probe test over in-memory metadata.
let Some(stats) = chunk.statistics().filter(|s| !s.is_min_max_deprecated()) else {
return true;
};(Scoping it to Statistics::ByteArray would keep the integer bounds, whose signed order is correct, if you'd rather not give those up. The page index is fine as is — it post-dates PARQUET-686 and carries a type-defined order.)
| } | ||
| if let Some(endpoint) = &io.s3_endpoint { | ||
| builder = builder | ||
| .with_endpoint(endpoint) |
There was a problem hiding this comment.
Optional (defense in depth) — s3_endpoint is SSRF-checked at the HTTP route (routes/delta.rs → guard_connection_urls), but store::open hands it to AmazonS3Builder::with_endpoint unchecked.
The Iceberg storage layer re-validates at client construction as well (fluree-db-iceberg/src/io/storage.rs:340 and :397), so a Delta record that arrives by any other path (the Rust API, a local CLI, a record replicated from elsewhere) gets the metadata-IP guard on the Iceberg side but not here.
A fluree_db_iceberg::net::validate_s3_endpoint(endpoint)? next to with_endpoint would match. This is minor and non-blocking — but if you agree it's right, I'd rather see it folded in now than lost in the backlog.
| std::cmp::Ordering::Greater => return Err(self.version_not_found(version)), | ||
| // Older than latest: the log no longer reaching it (cleanup) | ||
| // is the expected failure, so report it as the missing pin. | ||
| std::cmp::Ordering::Less => self.pinned(version).map_err(|e| { |
There was a problem hiding this comment.
Optional — Every failure to replay a version older than latest becomes VersionNotFound, with the real error at debug!.
This is more of a question than a suggestion. The expected case (log cleaned past it) deserves exactly that message, but a transient 503, an expired credential, or an unsupported feature at that version would also surface to the user as "has no readable version N", which sends them looking for a retention problem.
Maybe classify: map to VersionNotFound only when Kernel reports the log segment can't reach the version (or is_missing_file()), and propagate anything else as DeltaError::Kernel? Minor — but if you agree, I'd rather see it in this PR than lost in the backlog.
There was a problem hiding this comment.
Addressed in 4a0fe4d. Kernel reports the log-cleaned case as a plain Generic("No files in log segment"), so rather than match that string, storage-access failures (non-NotFound ObjectStore / IOError, Reqwest) and Unsupported are picked out by variant and propagate as themselves; everything else stays VersionNotFound.
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn unknown_versions_are_errors_not_the_latest_table() { |
There was a problem hiding this comment.
Optional (regression-proofing) — The docs promise "a table that requires a reader feature the reader does not implement is refused, never read partially," and that is true — but nothing in our suite pins it, and registration doesn't see it.
I checked it with a probe that rewrote a copy of flags's protocol to minReaderVersion: 3 + an unknown reader feature, and separately to minReaderVersion: 4; both reads fail with Kernel's Unsupported: Feature '…' is not supported / Unsupported minimum reader version 4.
Two things surprised me, though. The refusal comes from scan_builder().build(), not from snapshot() — snapshot(Latest) succeeds and the error arrives as the first stream item — which means the registration probe (delta.rs:226-238, which only calls batch_schema) reports such a table as readable with a version and no warning, and the first query is where it fails. And nothing in our suite pins any of this; it's Kernel's behaviour, and =0.28.0 + internal-api makes every Kernel bump a deliberate change.
So maybe: have the registration probe plan a scan (e.g. snapshot.file_count(&[])) so an unsupported table is a table_warnings entry at map time, and add a test next to unknown_versions_are_errors_not_the_latest_table that stages a patched-protocol copy and asserts both the registration warning and the query error. Happy to share the probe; it's ~60 lines.
There was a problem hiding this comment.
Addressed in 4a0fe4d. Registration now builds the scan (batch_schema), so an unsupported table is a table_warnings entry at map time.
| /// prune is only sound when the predicate maps to EXACTLY ONE scalar object map | ||
| /// backed by one column (else a row could match via an unpruned column); otherwise | ||
| /// no filter is pushed and the operator's residual check remains the authority. | ||
| /// The scan filters `pattern` pushes to a scan of `triples_map`'s table: its |
There was a problem hiding this comment.
Optional (nit) — The new pattern_scan_filters was inserted between push_scalar_eq_filter and its doc comment.
So the old comment (1964-1971, "Push an Eq scan filter for a scalar constant-object equality…") now prefixes pattern_scan_filters's doc and push_scalar_eq_filter at 2067 has none. Moving those eight lines back down above fn push_scalar_eq_filter fixes both.
| match &*lock(&self.files) { | ||
| Files::Listed(listing) => Files::Unlisted(Some((self.version(), listing.clone()))), | ||
| Files::Unlisted(prior) => Files::Unlisted(prior.clone()), | ||
| Files::Unbounded => Files::Unbounded, |
There was a problem hiding this comment.
Optional (perf nit on the log cache) — A version whose listing didn't fit the budget becomes Files::Unbounded, and successor_files carries Unbounded forward to every later version.
I don't think this matters much, but it means a big table that first arrived while other tables held the budget stays unlisted for the handle's whole TTL even after room frees up (only a full replay resets it to Unlisted(None)).
Returning Unlisted(None) for Unbounded in successor_files would let each new version retry. Minor and non-blocking — if you agree, folding it in now beats a backlog issue.
| } | ||
|
|
||
| impl ReadOnlyStore { | ||
| fn check(&self, location: &Path) -> object_store::Result<()> { |
There was a problem hiding this comment.
Praise — Re-checking the local allowlist on every read rather than only at registration is exactly right for a format whose log can name data files by absolute URI.
And wrapping every store read-only means Kernel can never be talked into a write. I traced object_store 0.13's defaults: head and get_range route through get_opts, so nothing bypasses check.
| size: u64::try_from(file.size) | ||
| .map_err(|_| DeltaError::Internal(format!("data file size {}", file.size)))?, | ||
| }; | ||
| // A deletion vector addresses rows by position in the whole file, so |
There was a problem hiding this comment.
Praise — Decoding a deletion-vector file whole because the vector is positional is the subtle correctness point of the pruned reader, and it's guarded and tested.
I mutated the guard off and pruning.rs:156 goes red with the deleted row 1023 back in the result — exactly the failure it exists to prevent.
| @@ -0,0 +1,531 @@ | |||
| //! A Delta graph source must answer every query exactly as a native ledger | |||
There was a problem hiding this comment.
Praise — A 66-query differential against a native twin restated from the generators' inputs, paired with a routing stamp that deletes a partition's files so a fast path must not touch them.
That's the right way to test a pushdown lane: agreement proves the semantics, the stamp proves the path fired.
9712e0c to
6924989
Compare
Centralize CLI and server telemetry, opt callers into HTTP form/query features, and update the standalone load tool. Select the async OTLP client for the Tokio batch processor and cover span delivery on shutdown with a local collector test. Document platform certificate trust.
Generate synthetic Delta history with explicit expected rows and validate Kernel logical scans locally and on S3. Include pinned development tooling, an AWS profile bridge, and dependency findings while keeping the experiment outside the production workspace.
Delta Kernel 0.28 owns the table protocol: log replay and checkpoints, reader-feature checks, column mapping, partition values and deletion vectors. The crate selects a version, asks Kernel for that version's logical rows, and converts them to fluree-db-tabular batches through the bridge proven in scripts/delta-spike. Tables are never written. Version selection carries the graph-source time-travel contract: an exact version, or the latest version committed at or before an instant (after the latest commit selects the latest; before the oldest reconstructable commit is a typed error naming that commit). A version the log no longer reaches, or one past the latest, is an error rather than a different version. Every object store is wrapped read-only. Local tables reuse the Iceberg local-root allowlist, enforced per read as well as at open, because a Delta log may name data files by absolute URI. Kernel is adopted as published. Its arrow-58 feature hard-enables object_store 0.13 with its cloud backends in the core crate, which still use reqwest 0.12, so a build with this crate links both reqwest versions. The spike's object_store backport is dropped in favour of accepting that until upstream moves to object_store 0.14. Fixtures are committed copies of the spike generators' output: delta-rs tables for rewrite history and schema evolution, Delta Spark tables for deletion vectors, column mapping, a removed historical data file, and in-commit timestamps (new in spark_fixture.py, so timestamp selection is testable on a checked-out table whose mtimes mean nothing).
A `GraphSourceType::Delta` record (`f:DeltaMapping`) is an R2RML mapping over Delta tables, behind the new `delta` feature of fluree-db-api. It rides the existing R2RML provider the way SQL sources do: a per-query memoized source lookup dispatches scans, so mappings, joins, policy and both query surfaces work unchanged. - Config: tables are named by path. `rr:tableName` resolves to an explicit `tables` entry, else its dotted segments become directories under `root` (`dbo.orders` -> `<root>/dbo/orders`, the OneLake `Tables/` layout). - Registration compiles and stores the mapping, then probes each mapped table: its current version is reported, an unreadable table is a warning (it may not exist yet), and an unplaceable name is an error. - One version per table per query. The first touch resolves the version and every later scan or count in the query reads it, so a commit landing mid-query cannot split the query across versions. - Time pins follow the contract Iceberg sources set: `@snapshot:<n>` is the Delta version, `@time:`/`@iso:`/`@recorded:` select the latest version at or before the instant, `@t:`/`@commit:` are refused, and an unsatisfiable pin is `SnapshotNotFound` / `NoSnapshotAtTime`, never another version. Columns resolve against the pinned version's schema. - COUNT declines the metadata shortcut and counts a scan of the same pinned version; a sound Delta count needs per-file statistics net of deletion vectors. Scan filters and top-k are advisory and not pushed down yet. - Materialization refuses a Delta source by name. Mapping registration was duplicated between the Iceberg and SQL sources and would have gained a third copy; `register_r2rml_mapping` now serves all three. Two edge cases converge on the stricter existing behaviour: an Iceberg mapping given by address is checked for `rr:sqlQuery` at registration like inline content already was, and on a backend without address reads it is an error rather than an unvalidated registration.
`fluree delta map|list|info|drop` and `POST /v1/fluree/delta/map` register a Delta graph source; list/info/drop are the shared mapped-source commands, now including the Delta type. Both sit behind a new opt-in `delta` feature on the server and CLI: it links Delta Kernel and object_store (and with them a second reqwest major), so it stays out of the default build until the release artifact has been measured with it on. A CLI built without it can still map and query Delta sources on a server that has it. Registration now probes each table for exactly the columns its maps project, so a mapped column the table lacks (or one of a type the batch model cannot carry) is a warning at registration, while an unmapped nested column is not. Docs: a Delta graph-source guide (what the reader honors, registration, types, per-query version consistency, time travel and its failure modes, limitations), the CLI page and HTTP endpoint reference, and the Delta cases in the time-travel concept and Iceberg pages.
A Delta location may now be `abfss://<container>@<account>.dfs.core.windows.net/…` or the OneLake form `abfss://<workspace>@onelake.dfs.fabric.microsoft.com/<item>/…`, served by object_store's Azure backend (already linked through Kernel). With `<item>/Tables` as the root, the dotted-name layout addresses a lakehouse's `Tables/<schema>/<table>` directly. The location must name its storage host in full. The fsspec short form, a foreign host, a look-alike suffix and cleartext `abfs://` are refused, so a stored location cannot steer credentials to another endpoint. Credentials are the ambient Azure chain (AZURE_* variables, workload identity, managed identity) unless the source names a Microsoft Entra service principal. Its secret is a ConfigValue: an environment variable of the reading process (`--azure-client-secret-env`, nothing stored), a literal, or, from the Rust API, a secret reference resolved through the injected SecretResolver. The table-handle cache stays keyed on the config as stored, so a rotated secret behind a reference does not re-key it. A partial service principal is an error rather than a silent fall back to ambient credentials, and an unresolved reference fails closed at open. An ignored network test sends a bogus principal as far as Entra rejecting it, which proves the store's own reqwest 0.12 / rustls stack completes a handshake next to the workspace's reqwest 0.13 in one binary; it passes on macOS. Not yet verified: Linux targets, and a read of a real ADLS or OneLake table. Docs also correct the S3 credential description: the store reads environment credentials, web identity and roles, not shared-config profiles.
The empty-result check filtered Kernel's output down to rows matching the unsatisfiable predicate before asserting it was empty, so it passed for any reader. It now asserts that data skipping returns no rows at all: every fixture file carries min/max statistics for its key. The future-version check accepted any error, so a listing or credential failure counted as "version rejected". It now requires Kernel's log-segment end-version mismatch, the only form 0.28 reports it in. Both fixtures still pass (basic: 6 snapshots / 18 scans; Spark: 10 / 32, now including the in-commit-timestamp table). The probe's lockfile follows the workspace version of its fluree-db-tabular path dependency.
Request policies reach a Delta source through the shared R2RML gate, but the registered model ledger and default-allow are read from the record by Delta-specific code that nothing exercised. Covers an inline property deny (and that it leaves other properties alone), default-deny with no matching rule, and a governed source whose model hides a property for anonymous requests and grants it to an identity holding a policy class, including a request with no options at all. Mutation-checked: dropping the record's policy config makes the governed assertions fail.
The per-query version memo held one async lock across log replay, so a query over several Delta tables resolved them one after another, and the provider's table prefetch did nothing for a Delta source (it ran the Iceberg loader, which refuses the record). Each table now has its own once-cell: tables resolve independently, concurrent readers of one table share a single replay, and the first resolution still fixes the version for the rest of the query. `prefetch_tables` warms a Delta source's tables together under the query's pin.
A Delta version whose log still replays but whose data was vacuumed resolves and then fails at scan. The failure was the raw storage error (Arrow/HTTP text with the object URL). It is now an explicit message naming the table and version and the cause; the classification was already in `DeltaError::is_missing_file`. Seen against a real ADLS Gen2 account, where the underlying error is a 404 BlobNotFound; the fixture test covers the local-filesystem form.
`SELECT (COUNT(?o) AS ?n) WHERE { ?o ex:total 600 }` over a Delta source
counted every row of the table. The single-scan fused aggregate resolved only
the folded `star_constraints` to per-row checks; a standalone `?s pred const`
member stays `predicate_filter`/`object_constant`, and for that the fold relied
on the pushed scan filter having removed the non-matching rows.
That filter is pruning, not semantics: the provider contract lets an
implementation apply it inexactly or not at all, the Delta scan does not apply
it, and the Iceberg reader itself keeps every row when a literal cannot be cast
to the column type. The semi-join path already gathers both forms for exactly
this reason ("would leave the membership UNFILTERED"); the single-scan site now
uses the same resolver, renamed `resolve_pattern_constraints` since it is no
longer semi-join specific. A constrained plan still declines the metadata COUNT
shortcut, as before.
Found by reading a Fabric-written table on OneLake: the row query returned 166
rows and the COUNT over the same pattern 500. The regression test compares
COUNT against the row query for a constant object, a class plus constant, and a
FILTER, on a source whose scan ignores filters; it fails without the fix (6
instead of 1) and with the fused path disabled it passed, which is what
isolated the lane.
`FILTER(?b = false)` and `FILTER(?b = true)` matched nothing on any mapped source (Iceberg, SQL, Delta). The operator coerces a typed column value from its string form to a native value only for an allowlist of datatypes — numeric and temporal — so an `xsd:boolean` column stayed a string-backed `"false"^^xsd:boolean`, and equality between that and a real boolean does not match. `FILTER(!?b)` and the constant-object form `?s ex:flag false` take other paths and were unaffected, which is why it went unnoticed. Boolean joins the allowlist, for the same reason the comment there already gives for dateTime. Found on a Fabric-written OneLake table, the first mapped table with a boolean column to go through a FILTER. The test uses a small delta-rs fixture with a nullable boolean and checks `=`, `!=` and `!` in SPARQL plus the JSON-LD twin; it returned no rows before the fix.
…aph sources A SPARQL connection query whose builder carries `connection_opts` returned no rows, and no error, for any graph source named in `FROM` — Iceberg, SQL or Delta. That branch exists for the multi-query dispatcher's merged policy options, and it ran the dataset without the builder's graph-source providers, so the scan went to the no-op provider. The other branches of the same four entry points thread the providers through. Every server SPARQL request on `POST /query` takes this branch, with or without policy headers, because the route always attaches the bound governance options. `POST /query/<source>` and JSON-LD `from` were unaffected, which is how it stayed hidden. The two `…_with_opts_options` functions now take the providers and run the dataset with them when present. Found by the first test to drive a graph source through the server's SPARQL connection route. The regression test uses the Iceberg fixture, since the bug is not Delta's: all four entry points (`execute`, `execute_formatted`, `execute_formatted_string`, `execute_tracked`) are asserted, and each assertion was watched failing with its own site reverted.
…es, partitions Four more tables from the Delta Spark generator: - `checkpointed`: thirteen commits, so Spark's checkpoint at version 10 is on the read path. - `log_cleaned`: the same table after log retention — only the checkpoint and the commits after it remain, so earlier versions cannot be rebuilt. - `types`: every scalar type a mapping can address (byte through long, float, double, two decimals, date, timestamp, timestamp_ntz, string, binary, boolean) with a row of nulls, written by Spark rather than assembled as Arrow arrays. - `partitioned`: six files whose partition values and id ranges are disjoint, so a predicate on either provably excludes whole files.
`POST /delta/map` had no test, and no query had gone map → server → HTTP. This maps the `in_commit_time` fixture through the route and queries it on `POST /query` as SPARQL (`FROM`, latest and `@snapshot:` pinned, and a version the table never had) and as JSON-LD (`from`), then on `POST /query/<source>`. The SPARQL connection queries are what exposed the dropped graph-source providers fixed earlier in this series. The refusals cover a root outside the local allowlist, half a service principal, and an `s3_endpoint` aimed at the instance metadata service. With the SSRF guard disabled that last request is answered 201 after an outbound call to the endpoint, so the assertion is not vacuous. Compiled into `grp_query` only with the `delta` feature.
The Delta scan read every file of a table, one at a time, in 1000-row batches, and handed every row to the R2RML operator to be built into RDF terms before the query's FILTER saw it. It now does what the Iceberg scan does with the filters the engine already pushes: - **File skipping.** Pushed filters become a Kernel predicate, so a file whose partition values or min/max statistics rule the predicate out is never opened. - **Row filtering.** The same filters are evaluated over each decoded Arrow batch, so rejected rows never reach the operator. A filter on a column the scan does not project still skips files. - **Counts from the log.** `table_row_count` sums the per-file `numRecords` when that provably equals a scan: every file records one, none carries a deletion vector, and no counted column can hold a null. The null proof is a planning pass with `IS NULL` on those columns — data skipping keeps a file unless its statistics exclude a null, so an empty plan is the proof, and missing statistics decline rather than assume. - **Parallel reads.** Files are read by up to one worker per core through one shared multi-threaded runtime (previously a thread per cached table handle), in 8192-row batches. `FLUREE_DELTA_SCAN_CONCURRENCY` overrides. One rule governs both uses of a filter: it is pushed only when its value has the column's own physical type, so the comparison made in the reader is the one the engine makes. Decimals, `float` columns, a zero `double` (Arrow orders -0.0 below 0.0) and non-canonical template keys are left to the engine, as is top-k. 8M rows, 32 files, 8 partitions, local disk, release build, wall clock with CLI start-up; results byte-identical before and after: COUNT of the table 161 ms -> 30 ms SUM … GROUP BY region 453 ms -> 253 ms lookup by id (statistics) 6603 ms -> 32 ms lookup by bound subject 5401 ms -> 37 ms range on id AND amount 6310 ms -> 50 ms filter on an unclustered column 5980 ms -> 44 ms aggregate over one partition 664 ms -> 542 ms The last barely moves because fused aggregates pass no filters to any scan, Iceberg included; that is an engine change and is not made here. Correctness is pinned by a differential test: 66 queries — every comparison, IN/VALUES, constant objects and subjects, each aggregate lane, top-k, nulls, negation, joins — run against the Delta source and against a native ledger holding the same triples, and must agree. With the two engine fixes earlier on this branch reverted it reports exactly their four queries. Because agreement cannot show that a fast path fired, a second test deletes one partition's data files: filtered queries and the bare count succeed only if they never open them, and the unfiltered scan fails. Each guard (predicate built, deletion vectors, null proof, provider routing, a wrong row comparison) was broken in turn and watched failing. Reader tests now also cover a checkpointed log with and without its early commits, `@time:` before the oldest retained commit of a cleaned log, and every scalar type as Spark writes it.
… scan The fused aggregate lane scanned its fact table with no filters, on every source type: `COUNT`/`SUM`/… over `?s ex:region "east"`, or a GROUP BY with a FILTER, read the whole table and rejected rows in the fold, while the same pattern without the aggregate pruned files and rows at the scan. The single-table fold now pushes what the generic lane pushes. `R2rmlScanOperator::build_scan_filters` becomes the free function `pattern_scan_filters`, shared by both lanes. The fold takes its FILTER from the query rather than from the rewrite, so its pattern carries no pushed comparisons; they are collected from the FILTER with the rewrite's own `collect_pushdowns`. Nothing about the fold changes: every pushed filter restates a condition it already enforces per row (`filter`, `fact_constraints`), and it declines bound subjects, so a provider that applies a filter exactly, partly or not at all yields the same answer. The fact⋈dim and semi-join folds still push nothing. Their dim and membership scans must not (keep-min has to see every row before the constraint), and their fact scan is left for a follow-up. Delta, 8M rows / 32 files / 8 partitions, local disk, release, wall clock with CLI start-up; results byte-identical to the unoptimised build: aggregate over one partition (constant object) 551 ms -> 192 ms GROUP BY status, FILTER on the partition column 1782 ms -> 275 ms GROUP BY region, FILTER on a clustered id 1410 ms -> 124 ms The missing-partition stamp test gains three folded aggregates: with the change reverted the first fails by opening a file its filter excludes. The 66 differential queries still agree with the native twin, and the fused, graph source, Iceberg, SQL and pushdown-lane suites pass unchanged.
The `log_cleaned` table has no in-commit timestamps, so `@time:` resolves by log-file mtime, and a checkout does not preserve mtimes: the test passed against the generator's copy and failed in CI, where version 10 was no longer the oldest by mtime. It now stages a copy with known mtimes, as the other mtime test does, and also pins the boundary between versions and the oldest instant the refusal reports.
Each query replayed the table's whole log: once to resolve the version and again for every scan and count. A table handle now remembers the last version it resolved with that version's data-file listing. An unpinned read lists the log for commits past it and reads only those, so it still sees every new commit; a repeat read of an unchanged table costs one LIST and one HEAD. Scans of one version plan from the kept listing, where file skipping still applies. The four most recently used pinned versions are kept the same way. A log that is no longer the one remembered (a table dropped and rewritten in place) is detected by its tip commit's size and time and replayed. Listings are bounded process-wide by FLUREE_DELTA_LOG_CACHE_MB (0 disables). Planning from a kept listing uses Kernel's internal-api feature; the exact version pin contains it.
…kept Kernel's file read takes no row selection and re-fetches every footer on every query: on ADLS a warm point lookup spent 80 ms on two footer requests and 310 ms fetching the projected columns of a whole file to return one row. The reader now opens data files itself. Footers, with their page indexes, are kept process-wide (files are immutable; FLUREE_DELTA_FOOTER_CACHE_MB) and a cold one is fetched in one request. The pushed filters are checked against row-group statistics and the page index, and only row groups and pages that may hold a match are fetched and decoded; the exact row filter still runs on what is decoded. Integers, dates, doubles, strings and INT64-microsecond timestamps are compared; anything else keeps its rows. A file with a deletion vector is decoded whole, since the vector addresses rows by position. Matching file columns to table columns remains Kernel's.
…LI build fluree-db-api keeps `delta` off by default, so embedders (and builds using default-features = false) opt in.
The standalone probe crate and its S3 credential bridge were the experiment fluree-db-delta replaced. The two generators stay, under scripts/delta-fixtures, and the delta-rs one now also writes the `flags` table, which had been made by hand.
The client assumed every route sat under `/v1/<warehouse>`. That is what Polaris answers, but the prefix is the catalog's to choose: the Iceberg REST specification has a client send the warehouse to `/v1/config` and use the `prefix` it returns. Unity Catalog returns `catalogs/<name>`, so mapping a Databricks table with `--warehouse <name>` failed with ENDPOINT_NOT_FOUND on the first table load. The prefix is now looked up once per (catalog, warehouse) and kept for the process, since clients are built per request. `overrides.prefix` wins over `defaults.prefix`; a catalog that names none is addressed under `/v1`. A catalog with no config route keeps the warehouse as its prefix, as before; any other failure of that route is surfaced rather than read as "no prefix". Checked live against Unity Catalog's Iceberg endpoint on a UniForm table, with vended S3 credentials and no ambient AWS credentials.
…icks The reference pages say which credentials Fluree accepts; they did not say how to get from a table in a platform to a working source. This page does: which route fits which kind of table, where a table's location is found, how to create a service principal and what role it needs on each platform, what Unity Catalog has to have switched on, which token scope its Iceberg endpoint demands, and what the errors met along the way mean.
…s vending needs A service principal's OAuth token is requested and renewed by the Iceberg source, so it is the route for a standing deployment; a personal access token is not. Credential vending needs USE CATALOG, USE SCHEMA and SELECT besides EXTERNAL USE SCHEMA, even for a principal that can already see the table, and the Iceberg endpoint answers a principal lacking them without credentials rather than with an error — the page now says what that looks like and how to find the missing privilege.
`--auth-bearer` and `--oauth2-client-secret` store the secret with the graph source. `--auth-bearer-env` / `--oauth2-client-secret-env` (and the `auth_bearer_env` / `oauth2_client_secret_env` request fields) store only a variable's name, read from the environment of the process that reads the tables — the form the stored config already understood and no surface could produce. Unlike the Delta Azure secret, which only ever goes to the Microsoft login host, an Iceberg secret is sent to a catalog or token URL the same request chooses. Over HTTP that would let a caller name any variable of the server and receive it at a host of their choosing, so a server accepts only names its operator lists in FLUREE_GRAPH_SOURCE_SECRET_ENV_VARS, on map, browse and preview alike. A local CLI reads its own environment and may name any. The literal, secret-reference and variable forms now go through one setter per auth kind (`with_auth_bearer_value`, `with_auth_oauth2_secret_value`); the existing setters delegate to them.
6924989 to
88f0bd4
Compare
- A scan's planner and per-file workers wait on storage and on the consumer for the whole scan. They ran on the caller's blocking pool, so concurrent Delta scans could hold every thread that the server's file-backed storage reads need, and a query joining Delta with a file-backed ledger could deadlock. They now run on the Delta runtime's own pool. - Row-group pruning ignores statistics that parquet-rs flags as deprecated. Writers before PARQUET-686 (parquet-mr < 1.10) recorded string bounds in signed byte order, which exclude non-ASCII values, so matching rows were silently skipped on files from old writers (for example after CONVERT TO DELTA). - `store::open` applies the S3 endpoint SSRF check itself, as the Iceberg storage layer does, so a record that arrives other than through the HTTP route is also checked. - Registration plans a scan, so a table needing a reader feature Kernel does not implement is a table warning when it is mapped, not a failure at the first query. Tests pin Kernel's refusal for an unknown reader feature and for minReaderVersion 4. - A failure to replay an older version is reported as VersionNotFound only when the log no longer reaches it. A storage failure (403, 503, expired credentials) or an unsupported feature is reported as itself. - A version whose file listing did not fit the shared budget no longer passes that on to later versions; each new version retries. No dedicated test: it needs other tables to hold the budget.
When /v1/config returned 404, the fallback (the warehouse name as the prefix) went into the process-wide prefix cache with no TTL, so a single transient 404 (a gateway mid-deploy) fixed that fallback until restart. Only a prefix the catalog actually names is cached now. The fallback costs one extra GET per client build.
|
On the process notes:
|
Stacked on #1897 (→ #1896); re-target to
mainas those merge.What
Delta Lake tables as R2RML graph sources, read in place from local disk, S3, ADLS Gen2 and OneLake.
fluree-db-delta(new crate): a read-only table reader over Delta Kernel 0.28's default engine. Version selection by number or timestamp, projection, deletion vectors, column mapping. The object store is wrapped so writes are refused and local reads are re-checked againstFLUREE_ICEBERG_LOCAL_ROOTSon every read, not only at registration.GraphSourceType::Delta/f:DeltaMapping, dispatched fromFlureeR2rmlProviderthe same way the SQL source is. Tables are addressed by path: an explicittablesentry, else<root>/<dotted name as directories>(which is OneLake'sTables/<schema>/<table>layout).@snapshot:<n>is a Delta version,@time:selects by commit timestamp (in-commit timestamps when the table has them, file mtime otherwise). Unknown version, instant before the oldest retained commit, and a vacuumed version each get their own error.COUNTis answered from the log'snumRecordswhen that provably equals a scan (no deletion vectors, statistics present, no possible null). Files are read in parallel. A filter is pushed only when its value has the column's own physical type.FLUREE_DELTA_FOOTER_CACHE_MB, default 128) and a cold one is fetched in one request. The pushed filters are checked against row-group statistics and the page index, and only the row groups and pages that may hold a match are fetched and decoded; the exact row filter still runs on what is decoded. Integers, dates, doubles, strings and INT64-microsecond timestamps are compared; anything else keeps its rows. A file with a deletion vector is decoded whole, because the vector addresses rows by position. Matching file columns to table columns is still Kernel's.FLUREE_DELTA_LOG_CACHE_MB(default 256,0off). Planning from a kept listing uses Kernel'sinternal-apifeature, contained by the exact=0.28.0pin.AZURE_*, CLI, managed identity) or a service principal whose secret is aConfigValue(literal / env / secret ref), redacted inledger_info.fluree delta map|list|info|drop,POST /delta/map, docs underdocs/graph-sources/delta.mdanddocs/cli/delta.md.docs/graph-sources/lakehouse-platforms.mdwalks through ADLS Gen2, OneLake and Databricks end to end.fluree iceberg mapgains--auth-bearer-env/--oauth2-client-secret-env(request fieldsauth_bearer_env/oauth2_client_secret_env), which store a variable's name rather than the secret. An Iceberg secret is sent to a URL the same request chooses, so over HTTP a name must be listed by the operator inFLUREE_GRAPH_SOURCE_SECRET_ENV_VARS— otherwise a caller could have the server send any of its environment to a host of theirs. Eight mutations, each caught; checked live against Unity Catalog with a service principal (OAuth client credentials) and a personal access token, through the CLI and through the server.deltafeature is on by default in the server and CLI (measured cost on the release CLI: +8.96 MiB) and off influree-db-api, so embedders anddefault-features = falsebuilds opt in.Shared fixes found along the way
None of these is Delta-specific; each reproduces on Iceberg and SQL sources and can be split into its own PR against
mainif preferred.fix(query): SPARQL connection queries with governance options read graph sources— onmain,POST /querywith SPARQLFROM <graph source>returns no rows and no error: the builder'sconnection_optsbranch ran the dataset without the graph-source providers, and every server SPARQL connection request takes that branch.POST /query/<source>and JSON-LDfromwere unaffected. All four builder entry points are pinned, each mutation-checked.fix(r2rml): fused aggregates enforce a standalone constant object—COUNTover?s <p> <const>counted every row on the single-scan fused path.fix(r2rml): a mapped boolean column compares equal to a boolean literal—Booleanwas missing from the typed-literal coercion allowlist.perf(r2rml): a single-table fused aggregate pushes its filters to the scan— the fused lane scanned its fact table with no filters on every source type, so an aggregate over one partition read the whole table.fix(iceberg): the REST catalog's route prefix comes from /v1/config— the Iceberg REST client assumed every route sat under/v1/<warehouse>, which is what Polaris answers. The specification has the client send the warehouse to/v1/configand use the prefix returned; Unity Catalog returnscatalogs/<name>, so mapping a Databricks table with--warehouse <name>failed withENDPOINT_NOT_FOUND. The prefix is now looked up once per (catalog, warehouse); a catalog with no config route keeps the warehouse as its prefix, any other failure of that route is surfaced. Seven mutations, each caught. Not checked against Snowflake Horizon or Glue (no account in reach) — the 404 fallback is what keeps a catalog without the route working.Numbers
8M rows / 32 files / 8 partitions, local disk, release build, wall clock including CLI start-up; every result byte-identical to the unoptimised build.
COUNTof the tableGROUP BY,FILTERon the partition columnGROUP BY,FILTERon a clustered idSUM … GROUP BYover the whole tableThe same table on ADLS Gen2 (32 commits, no checkpoint), server mode, from a laptop to
eastus(~40 ms round trip), warm best of 4:COUNTof the tableGROUP BY,FILTERon a clustered idGROUP BY,FILTERon the partition columnSUM … GROUP BYover the whole tableWith the pruned reader and kept footers on top (previous binary re-run in the same session): lookup by id 518 → 228 ms, bound subject 674 → 226 ms,
GROUP BY+FILTERon a clustered id 703 → 579 ms, on the partition column 960 → 741 ms;COUNTstays at the 65 ms LIST + HEAD floor; queries that read most of a file or the table are unchanged (bandwidth-bound from a laptop). The traced lookup is now the freshness check plus one round of page-range requests, with no footer request.Before that change, a traced warm lookup (462 ms): 66 ms for the LIST + HEAD freshness check, 3 ms planning from memory, two ~40 ms Parquet footer requests, 310 ms for one request fetching the projected columns of the one file left after skipping. The log is no longer the cost; the data file is. Whole-table queries are bandwidth-bound from a laptop and need an in-region run.
Dependency note
Kernel's
arrow-58feature hard-enablesobject_store0.13, which pulls reqwest 0.12 alongside the workspace's 0.13. We accept the duplicate rather than patch a crate; it goes away when Kernel moves toobject_store0.14. TLS from that second stack was checked on macOS arm64 and linux/aarch64.Verified
IN/VALUES, constant objects and subjects, each aggregate lane, top-k, nulls, negation, joins — run against the Delta source and against a native ledger holding the same triples, and must agree. With the twofix(r2rml)commits reverted it reports exactly their four queries.@time:on a cleaned log, every scalar type as Spark writes it, row filtering per type including the cases that must be left to the engine.POST /delta/map, then SPARQL and JSON-LD queries (latest, pinned, unknown version) through both query routes; refusals for a root outside the allowlist, half a service principal, and an SSRFs3_endpoint.INand unprojected-column filters prune,!=and a file with a deletion vector decode everything (and the deleted row stays deleted), each comparable type prunes on Spark's own encodings while INT96 timestamps and booleans do not. Row-group pruning without a page index, the intersection of two filters' pages, and a millisecond-timestamp column that must not be compared are unit-tested over in-memory Parquet. Footer reuse is stamped by overwriting the files' closing magic after the first read. Seven mutations, each caught.--at, predicate construction, deletion-vector and null proofs for the count, provider routing, a wrong row comparison, the SSRF guard, each of the four connection-query sites.DELETE/UPDATE, column mapping with row tracking through rename/drop/re-add, liquid clustering withOPTIMIZEand v2 checkpoints with sidecars, a classic checkpoint the engine wrote read below and above it, type widening (a filter across both physical widths), a partition by a generated column, a UniForm table. Counts, sums, filters, lookups and pinned versions all equal the engine's own answers. AVARIANTcolumn is refused by name at map time and at query time. The UniForm table was also read through Unity's Iceberg REST endpoint with vended S3 credentials, which is what found the prefix bug above.Not verified / not built