Repository navigation
feat(iceberg): add AWS Glue Data Catalog + S3 Tables catalog modes - #1451
Conversation
Two native-AWS-SDK catalog modes for the Iceberg/R2RML graph-source path, at parity with REST (Polaris/Snowflake) and Direct: fluree iceberg map gs --mode glue --table db.tbl --region us-east-1 --r2rml m.ttl fluree iceberg map gs --mode s3tables --table ns.tbl --table-bucket-arn arn:... --r2rml m.ttl Both resolve the table's metadata_location via the native AWS SDK (aws-sdk-glue GetTable / aws-sdk-s3tables GetTableMetadataLocation) and read metadata/manifests /data from S3 with the ambient credential chain, reusing the existing direct.rs reader + from_default_chain. No aws-sigv4, no request signing, no REST prefix, no vended-credential parsing. Rationale: for a normally S3-authorized principal, neither Glue DC (IAM mode) nor S3 Tables vends credentials, so ambient reads suffice; and staying on the AWS SDK keeps consistent signing/transport paths rather than a hand-rolled REST+SigV4 client. Validated against a live Glue + S3 Tables harness (offline config tests + exact-count SPARQL e2e incl. multi-table joins and a dangling-FK check). - fluree-db-iceberg: GlueSdkCatalogClient + S3TablesSdkCatalogClient (catalog/aws_sdk.rs); CatalogConfig::Glue/S3Tables (serde glue/s3tables) — variant ungated, SDK impl aws-gated. read_glue example; offline config tests. - fluree-db-api: CatalogMode::Glue/S3Tables + to_iceberg_gs_config + two r2rml scan-path arms mirroring Direct. - fluree-db-cli / fluree-db-server: --mode glue|s3tables (+ --region, --catalog-id, --table-bucket-arn) on `iceberg map`, local and remote. - docs: graph-sources + CLI reference. Follow-ups: Lake-Formation-governed (vended-cred) Glue, and catalog browse for Glue/S3Tables.
7c83c7c to
d777a13
Compare
…query snapshot pin Before this, only map/query/list/info/drop worked for glue/s3tables; the read-only onboarding/introspection surface hard-rejected them, and the query path lacked the REST arm's per-query snapshot pin + catalog caches. Onboarding/introspection (catalog browse, table preview, R2RML auto-generate, mapping validate): - API: `rest_catalog_client` -> `catalog_client`, returning a boxed `SendCatalogClient` per mode (RestCatalogClient / GlueSdkCatalogClient / S3TablesSdkCatalogClient; Direct still rejected — no catalog to browse). Preview fetches + parses table metadata from S3 via `metadata_location` when the catalog returns no inline metadata (the SDK loadTable does), reusing the scan-path reader. generate/validate call preview per table, so they unblock transitively — no edits needed there. - Server: `IcebergConnectionRequest` gains region/catalog_id/table_bucket_arn; `build_iceberg_connection` gains glue/s3tables arms. Query-time (correctness + perf): - glue/s3tables scans now resolve loadTable through the same per-query snapshot pin + cross-query loadTable cache as REST (`sdk_resolve_load_table`), so every scan in a query reads one pinned Iceberg snapshot (was: independent per-scan SDK loads could observe different snapshots if the table committed mid-query), and the SDK client is built only on a genuine cache miss (was: rebuilt + a fresh GetTable/GetTableMetadataLocation per scan). Validated live: browse + preview against Glue (`examples/glue_onboarding.rs`); SPARQL e2e counts unchanged (300/60000/6/20000). Offline: iceberg_catalog + server route tests pass.
…3Tables Captures the PR's acceptance criteria as assertions (previously only exercised by hand-run examples), matching the repo's it_gcs_sdk_reads.rs live-test convention. - fluree-db-iceberg/tests/it_glue_sdk_reads.rs: SDK catalog load_table -> ambient S3 read -> scan row count, for Glue and S3 Tables. Env-gated (FLUREE_GLUE_IT_* / FLUREE_S3TABLES_IT_*); skipped when unset, so no live dependency in CI. Asserts an exact row count when FLUREE_*_EXPECT_ROWS is set. - fluree-db-api/tests/it_glue_live.rs: catalog browse + table preview via the public API, asserting browse lists the database and preview returns a schema. - catalog/aws_sdk.rs: factor the Glue metadata_location extraction into a pure fn with offline unit tests (present + missing-key error) — CI-level coverage of the one bit of the Glue read path that previously had none. Verified live against the sandbox harness: Glue dim_store=300, S3 Tables dim_geography=200, browse (3 namespaces / 11 tables), preview (8 columns, v2).
4acab4e to
dbbd901
Compare
…EST loadTable VendedCredentials only read vended S3 creds from the loadTable response's legacy top-level `config` map, never the standardized top-level `storage-credentials` array (apache/iceberg #10722) that S3 Tables / Lake-Formation-vended Glue / newer Iceberg REST catalogs return. Such a response yielded `credentials = None`, so the scan fell through to ambient creds and 403'd on the backing bucket — a permissions error masquerading as a parse gap. - `VendedCredentials::from_load_table_response(response, metadata_location)`: checks `storage-credentials` FIRST (spec-normative precedence), picking the longest prefix that yields *usable* static creds (a remote-signing-only entry carries no `s3.*` keys and is skipped), then falls back to the flat `config` map. - Factor the two duplicated REST loadTable parse blocks (the `CatalogClient` (?Send) and `SendCatalogClient` impls) into one shared `parse_load_table_response` — preserves the inline `metadata` + `config` passthrough; fixes once, kills the duplication. - Offline fixtures: precedence, longest-usable-prefix, non-matching-prefix -> config fallback, legacy config, malformed entries, none. Not hit by #1451's SDK-native AWS path (ambient by design); benefits spec-compliant REST vending catalogs (Polaris/Unity/Snowflake). The remaining follow-up (SDK-native Lake-Formation vended creds for Glue) is captured as an audit-hardened spec, deferred to a stacked PR.
| async fn list_tables(&self, namespace: &str) -> Result<Vec<String>> { | ||
| let out = self | ||
| .client | ||
| .get_tables() |
There was a problem hiding this comment.
These four list ops (get_databases/get_tables here, and list_namespaces/list_tables in the S3 Tables client) only read the first page. All are paginated — Glue defaults to 100 results + next_token, S3 Tables returns a continuation token — so browse silently truncates any catalog with >100 databases/tables. Loop on the token or use .into_paginator().send().
There was a problem hiding this comment.
Good catch. All four list ops page through now (into_paginator() on GetDatabases / GetTables / ListNamespaces / ListTables), in the merge commit 148b70ef9. While I was in there, Glue GetTables also keeps only Iceberg tables, using the same metadata_location test load_table applies, so browse can't offer a Hive table that would only fail on load.
| Ok(match self { | ||
| SdkCatalog::Glue { region, catalog_id } => Box::new( | ||
| fluree_db_iceberg::catalog::GlueSdkCatalogClient::new( | ||
| region.as_deref(), |
There was a problem hiding this comment.
The catalog client is built with only the mode region, but the S3 storage in the same scan arm (and the browse path in catalog_client) falls back region → io.s3_region. If a user sets only io.s3_region, GetTable resolves via the default-chain region while S3 reads use io.s3_region — mismatched, and it contradicts the CatalogConfig::Glue.region doc ("falls back to ... io.s3_region"). Thread io.s3_region into SdkCatalog so the fallback matches.
There was a problem hiding this comment.
You were right, and it was actually a bit worse once main's newer callers were counted: four sites with three different precedences. There's now one resolution in fluree_db_iceberg::config (CatalogConfig::aws_catalog_region / IcebergGsConfig::storage_io) that the scan path, the onboarding routes and /info all use. The Glue/S3 Tables API is called in region, else s3_region, else the SDK chain (S3 Tables uses the bucket ARN's region and refuses a region that contradicts it). S3 reads use s3_region, else the catalog's region. That last bit flips the original precedence for the data reads. I think an explicit s3_region should win there, since the data can live in another region than the catalog, but happy to talk it through if you see it differently.
| } | ||
| } | ||
|
|
||
| // Fall back to the legacy flat top-level `config` map. |
There was a problem hiding this comment.
Edge case in this fallback: if the only prefix-matching storage-credentials entry is remote-signing-only (no static s3.* keys) and a legacy top-level config carries static creds, we skip the matching entry and fall back to config's static creds — which can contradict the catalog's intent to remote-sign that prefix. Rare shape, likely fine, but worth a note on the precedence.
There was a problem hiding this comment.
I went a step further than a note here, fwiw. The longest matching prefix is now final: if it's remote-signing-only (no static s3.* keys), we return no credentials and §2 refuses the read, rather than falling back to a shorter entry or to the legacy config map. Both of those would be credentials the catalog didn't scope to this table. It's its own commit (bcc22892c) with tests for both shapes (longest_prefix_without_static_keys_yields_no_credentials, matching_remote_signing_entry_does_not_fall_back_to_legacy_config), so if you think fail-closed is too strict for that shape I'm happy to drop it back to a doc note.
bplatz
left a comment
There was a problem hiding this comment.
Several comments inline, approving so you don't have to wait after reviewing them.
|
Backlog-sweep nudge: this has been approved since 7/7 but is now conflicting and ~7 weeks stalled, and #1456 (Lake-Formation vended credentials) is explicitly unstartable until it lands. The rebase is over the BYO-IAM credential work (#1500/#1503/#1514, e.g. One thing the sweep flagged that raises the stakes a bit: the |
Brings the Glue / S3 Tables catalog modes up to main (2,900 commits since the 2026-07-06 merge-base) and re-threads them through main's current Iceberg architecture rather than beside it. Conflicts: - Cargo.lock: main's lock, re-resolved with aws-sdk-glue 1.142.1 and aws-sdk-s3tables 1.54.0, the newest releases compatible with main's locked smithy runtime. The lock only gains those two packages; the PR's 1.153.0 / 1.59.0 forced the shared AWS runtime (smithy-runtime, sigv4, aws-runtime) up under the HTTP/1.1-pinned S3 read path. - Cargo.toml manifests, cli.rs, docs/graph-sources/iceberg.md: both sides. - r2rml.rs, iceberg_catalog.rs: resolved by the re-threading below. Re-threaded onto main's patterns: - One loadTable ladder. main's REST ladder (per-query pin, cross-query cache, disk pointer rung, deferred LazyS3Storage, the #1896 time-pin guard, the section 2 fail-closed storage decision) now runs over Arc<dyn SendCatalogClient> for REST, Glue and S3 Tables (resolve_catalog_load_and_storage, catalog_session_storage). The PR's separate sdk_resolve_load_table copy, which predated the time-pin guard, is gone. - One process-wide catalog-client cache (R2rmlCache::catalog_clients, shared_catalog_client); Glue/S3 Tables clients are no longer rebuilt on every cache miss. A disk-pointer hit on a non-vending catalog builds its ambient storage without calling the catalog. - prepare_iceberg_scan (incremental / materialize) and ledger_info (/info catalog object) gained the arms main's new code needs. - Onboarding: rest_catalog_client becomes async catalog_client for all five callers (browse, preview, sample, storage verify, provisional query); metadata is read from metadata_location when a catalog returns none inline (load_response_metadata). - IcebergCreateConfig::to_iceberg_gs_config builds one IcebergGsConfig after the per-mode match, so delete / order_by / model / default_allow (added on main) cannot be dropped for a mode. - One catalog-mode dispatch for the CLI and both server builders (IcebergConnectionConfig::from_mode / IcebergCreateConfig::from_mode, CatalogModeError rendered per surface). glue / s3tables take --table only when no --r2rml mapping names the tables, as rest does. - One validation: the API delegates Glue/S3 Tables rules to CatalogConfig::validate_aws_sdk_catalog. Review follow-ups (bplatz, 2026-07-07): - Glue / S3 Tables listings page through every result. - One region resolution (catalog call: region, then s3_region, then the SDK chain, S3 Tables using the ARN's region; S3 reads: s3_region, then the catalog's region), shared by the query and onboarding paths. Also: - SDK errors carry their source chain (not "service error"); not-found becomes TableNotFound, access-denied becomes the new IcebergError::CatalogAccessDenied, lifted to err:catalog/AccessDenied (403) on the eager and deferred paths. - Glue browse lists only Iceberg tables. - glue / s3tables refuse vended_credentials = true (as Direct does), refuse a region that is not an AWS region code (it becomes part of a hostname), and parse the S3 Tables ARN (all partitions) and refuse a region that contradicts it.
Review follow-up. Among the loadTable `storage-credentials` entries whose prefix matches the table, the longest one is the catalog's decision for this table. When that entry has no static s3.* keys (e.g. it asks for remote signing, which this reader does not do), the result is now no credentials, so the source's vended-credentials policy refuses the read (section 2 fail-closed). Before, the parser fell back to a shorter entry's keys or to the legacy `config` map: credentials the catalog had not scoped to this table. The legacy map still applies when no entry matches at all.
They skipped by returning early when their env vars were unset, so CI's `nextest --all-features` run reported them as passing while they did nothing. Mark them #[ignore] with the env they need, as every other live Iceberg test is, and run them with --ignored. Use a placeholder AWS profile in the run instructions.
Every page that listed the catalog modes as REST and Direct now covers Glue and S3 Tables as well: the CLI and HTTP references (flags, fields, the verify route), the stored config format, the mode chooser, credentials, regions and endpoint overrides, and the lakehouse route table. The Glue troubleshooting entry described errors that do not exist in the code; it is replaced with the errors these modes actually return. The docs no longer claim that Lake-Formation-governed Glue tables can be read in REST mode, which has no SigV4 signing.
it_iceberg_glue_moto replays a committed fixture into moto (a local mock of S3 and the Glue Data Catalog) and reads it through the public API: - a table resolved through Glue GetTable; - the current metadata file among three; - the Glue pointer over an uncommitted 00099 metadata file; - a two-table join named by one mapping; - clear errors for a missing table and for a non-Iceberg (Hive) table; - browse (Iceberg tables only) and preview (schema read from S3). The fixture holds Iceberg tables written by pyiceberg's GlueCatalog (pointer in `metadata_location`, no version-hint.text), exported with their Glue registrations. The test seeds moto through the AWS SDK, so CI needs no Python. Glue reaches moto through AWS_ENDPOINT_URL_GLUE and S3 through the source's own s3_endpoint, which also pins that override. CI: the `test` job gets a pinned motoserver/moto service and FLUREE_GLUE_LOCAL_ENDPOINT. The test skips without it, and glue_moto_is_configured_in_ci fails when the job's FLUREE_GLUE_MOTO marker is set without the endpoint, as the live-bridge guard does. The `glue-moto` feature keeps aws-sdk-glue out of other fluree-db-api test builds. scripts/glue-local/ is the CLI-level harness this test came from, made repo-generic. It runs moto plus pyiceberg locally (pinned in requirements.txt), grades a fluree binary with check.sh, proves its expected counts with selftest.sh, and regenerates the fixture with write_fixture.sh. Each harness run gets a fresh TMPDIR so Fluree's disk caches cannot answer from an earlier run, and env.sh sets no S3 endpoint override, so check.sh proves --s3-endpoint is honored.
… Delta The lakehouse troubleshooting row said S3 reads ignore AWS_PROFILE and SSO. That is true of the Delta reader (object_store's from_env) and not of Iceberg sources, Glue and S3 Tables included, which use the AWS SDK's default chain. The aws_sdk module doc no longer claims that Lake-Formation-governed Glue tables can be read in REST mode (#1456).
Fluree's Iceberg disk caches (catalog pointers, metadata, Parquet) live under the temp dir and outlive the process. A re-run of it_iceberg_glue_moto, or a nextest retry, could therefore answer from the previous run's cache without asking Glue. It did: with the Glue client mutated to read `previous_metadata_location`, the four count checks still passed and only preview failed. The test now sets a fresh TMPDIR before building Fluree. Under the same mutation the counts come back 0 / 100 / 0 / 0 and fail, as do the not-found and browse checks under their mutations.
… internal error A REST catalog's 403, or a 401 that survives the token refresh, was an untyped `Catalog` string. Queries reported it as an internal error and onboarding as a config error. It is now IcebergError::CatalogAccessDenied, the same error a Glue / S3 Tables denial raises: - each load_table names the table it was loading (name_denied_table); - storage_query_error / storage_api_error lift it to QueryError::CatalogAccessDenied, HTTP 403, as Delta/Unity already do; - the lift covers queries, the provisional R2RML query, preview, sample and browse. The message keeps the "Catalog request failed (<status>): <body>" wording, because hosts classify verify failures by it. Status codes for a REST catalog denial change from 500 (query) / 400 (onboarding) to 403.
prepare_iceberg_scan (incremental and materialize scans) built REST clients and storage by hand: - it called create_provider_arc on un-hydrated auth, so a source whose catalog auth is a SecretRef could not be materialized at all; - it skipped the section 2 credential decision, so a source requiring vended credentials whose catalog vended none was read with the process's ambient AWS identity, though queries on the same source refuse. REST, Glue and S3 Tables now share one arm. It uses the process-wide client (shared_catalog_client, which hydrates) and catalog_storage, which is the query path's storage decision without the per-query client reuse (refuse_unvended_read, then build_catalog_storage). The only sources that newly fail are those whose queries already fail closed. /info row counts were REST-only: they read the metadata inline from loadTable, and Glue / S3 Tables return only its location. They now use the same shared client and catalog_table_metadata (inline copy, then the query path's caches, then one metadata read seeding those caches), so every catalog source shows its counts.
it_iceberg_glue_moto now also covers, on `orders` (two appends of 100): - materialize scans through prepare_iceberg_scan: a full scan (200), an incremental scan from the first snapshot (100), a scan pinned to it (100); - a query pinned with `@snapshot:` (100); - /info: catalog type `glue` and the row count read from the metadata file Glue points at (50). Reverting /info to REST-only drops the count and fails the check.
- Iceberg / R2RML troubleshooting showed error types the code does not have (`SchemaMismatchError`, `IcebergConnectionError`, `R2RMLMappingError`). They are replaced with what the code actually does: - the map-time parse/compile errors; - the `/iceberg/r2rml/validate` diagnostic codes; - at query time, a missing column reads as null, so rows drop out quietly; - the catalog and storage denials. - errors.md now documents err:catalog/AccessDenied (Iceberg REST, Glue / S3 Tables, Unity) beside the other 403s, and the Iceberg troubleshooting table covers a REST catalog's refusal. - materialize / track make a query's credential decision; noted where they are documented. - The server's own AWS identity is what reads direct / glue / s3tables sources (and REST ones with vended credentials off), so scope it to the tables it serves. - server-integration.md / endpoints.md: `r2rml` is optional inline Turtle (it was documented as a path, as auto-generating a mapping when omitted, and as accepting JSON-LD inline), local `table_location`s are accepted under FLUREE_ICEBERG_LOCAL_ROOTS, and a failed REST connection test does not fail the request.
map_iceberg takes `glue=fluree.Glue(region=..., catalog_id=...)` or `s3_tables=fluree.S3Tables(table_bucket_arn, region=...)` as the place the tables are found, beside `table_location` and `catalog_uri`. Exactly one must be given. The spec objects follow map_delta's `unity=fluree.Unity(...)`. The native side now parses the mode with IcebergCreateConfig::from_mode, the same dispatch the CLI and server use. That also fixes a REST source whose tables all come from the mapping (no `table`): it failed validation in Python with an empty table identifier, where the CLI and server already accepted it.
|
@bplatz — this had gone pretty stale (merge-base was 2026-07-06, ~2,900 commits behind), so I merged Your three inline comments: I replied in each thread. In short, the listings page through, region resolution is now one function shared by every path, and the Did the design still hold up against I wondered whether, designing this from What did change is how it plugs in. Glue and S3 Tables now go through
The textual conflicts themselves were small: the Tests The live The new regression test is
|
bplatz
left a comment
There was a problem hiding this comment.
Thanks for the re-thread. Routing Glue and S3 Tables through the shared loadTable ladder is a big improvement over the parallel copy. I'm good with SDK-native for this PR: the moto test that runs in CI makes the case, and REST + SigV4 can come with #1456.
Approving, but please review the inline comments before merging. The first one, the storage-credentials entry dropping the top-level region and endpoint, is a regression for existing REST users and should be fixed here. The pointer-cache one needs either a fix or a decision and a docs note. The rest are smaller.
Two things that don't anchor to a line:
- S3 Tables never runs in CI. Glue is covered end to end by moto. S3 Tables only has config and parse unit tests plus the ignored live test, so
GetTableMetadataLocation, its NotFound/AccessDenied classification on the wire, and S3 Tables browse never execute in CI. If moto 5.2.3 supports s3tables, it's worth adding to the same test; if not, please file a follow-up. - Labels: the PR has none, so it lands under "Other Changes" in the release notes. Could you add
area:icebergand a feature label?
| }) | ||
| .max_by_key(|(prefix_len, _)| *prefix_len); | ||
|
|
||
| let config = match best_entry { |
There was a problem hiding this comment.
When an entry matches, this builds the credentials from that entry's config alone, and the top-level config is never read. That's a regression for catalogs that put only the credential keys in the entry. Polaris (and Snowflake Open Catalog, which is built on it) puts s3.access-key-id / s3.secret-access-key / s3.session-token in the storage-credentials entry. client.region, s3.endpoint and s3.path-style-access are non-credential properties and go only into top-level config.
Parsing that shape here gives region None, endpoint None and path-style false. from_config_map(config) on main gives the catalog's values. So against a MinIO / S3-compatible store, reads go to real AWS S3 with MinIO keys, and a bucket outside the default region fails with a wrong-region error. Both work on main today. The Java S3FileIO layers the entry's properties over the table's rather than replacing them.
Suggested shape: start from the non-credential keys of the top-level config, overlay the matched entry, and take the credential keys only from the entry. That keeps the fail-closed rule from bcc22892c for an entry with no static keys. A test with region and endpoint only at top level next to a matching entry would pin it.
There was a problem hiding this comment.
Thanks @bplatz, you're right, and it's a real regression against main for the Polaris / Open Catalog shape: a matched entry replaced the top-level config wholesale, so client.region, s3.endpoint and s3.path-style-access just vanished. Fixed in 59bc07b with the shape you suggested (which I think is also what S3FileIO does): we start from the top-level config minus its credential keys, overlay the matched entry, and the credential keys (s3.access-key-id, s3.secret-access-key, s3.session-token, plus the two expiry keys) only ever come from the entry. So a remote-signing entry still yields no credentials and §2 still refuses, per bcc22892c, rather than reaching back for top-level keys the catalog didn't scope to this table.
a_matched_entry_keeps_the_tables_top_level_connection_settings pins region / endpoint / path-style at top level next to a matching entry, the entry's own region winning when it sets one, and the remote-signing case. Reverting the layering fails it.
| .await | ||
| .map(|(storage, _)| storage) | ||
| } else { | ||
| // A catalog that never vends (Glue, S3 Tables) |
There was a problem hiding this comment.
This needs a fix or an explicit decision. For Glue / S3 Tables, a pointer hit means queries never call the catalog until FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS (default 300s) runs out. Within that window:
- A table dropped in Glue, or a revoked
glue:GetTable/ Lake Formation grant, keeps being read with the ambient identity. - The pointer key is
load_table_key(graph_source_id, namespace, table)and doesn't include the config, and the disk cache has no way to invalidate an entry. So dropping a source and re-creating it under the same name with a differentregion/catalog_id/ ARN can serve the old table's data until the TTL expires. REST shares the key, but its forced build still callsloadTableunder the new config, which re-checks.
Could the pointer key include a hash of the catalog config, the way the client cache does? Separately, I'm fine with the bounded staleness for the access-check case if it's documented, so a note in iceberg.md that Glue / S3 Tables can serve a cached pointer for up to the TTL without asking the catalog would cover it.
There was a problem hiding this comment.
I went with both here, the fix and the docs note.
The key (3efcd36): the two caches that outlive a query, the in-memory cross-query loadTable cache and the disk pointer, now key on load_table_key(gs, ns, table) plus the source config's fingerprint (cross_query_key, the same config_fingerprint the client cache already uses). So a source dropped and re-created under the same name with another region / catalog_id / ARN / URI can't answer from the old one's entry. The per-query session pin stays on the bare key, since a single query only ever sees one config. cross_query_keys_follow_the_catalog_config pins it, and fails if the fingerprint is dropped from the key.
The staleness: I'm fine with it bounded too, as long as it's written down, so iceberg.md → Connection Issues now says plainly that a table dropped from Glue / S3 Tables, or a revoked glue:GetTable / LF grant, is noticed only once the window passes, and that 0 on either TTL restores ask-every-time. configuration.md also gets a row for FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS, which wasn't documented at all on main (its freshness note named the 60s TTL as the only freshness knob). One thing I tightened while writing it: the in-memory entry carries the vended credentials (CachedLoadTable, gated on creds_expired), so even a vending REST catalog isn't re-asked inside the 60s window. It's only past that, on a disk-pointer hit, that REST's forced build re-checks, and the docs say that rather than implying REST always does (2aa8808).
|
|
||
| For AWS S3 Tables, send `"mode": "s3tables"` and `"table_bucket_arn": "arn:aws:s3tables:us-east-1:123456789012:bucket/analytics"` in place of `region`; a Glue catalog in another account takes `"catalog_id": "123456789012"`. With `r2rml`, `table` may be omitted in `glue` and `s3tables` modes, as in `rest`: each `rr:tableName` names a table. | ||
|
|
||
| R2RML can be omitted to auto-generate a direct mapping. An optional `"model": "governance:main"` names the model ledger that governs the source (see [Access policy](#access-policy)). AWS credentials for `direct`, `glue` and `s3tables` modes come from the server's ambient AWS credential chain (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY`, `AWS_PROFILE`, `AWS_REGION`, or an attached instance role). See the [Graph Source Endpoints](../api/endpoints.md#graph-source-endpoints) section in the API reference for the complete request/response schema. |
There was a problem hiding this comment.
This still says R2RML can be omitted to auto-generate a direct mapping. Nothing does that: without r2rml, the route calls create_iceberg_graph_source, and this PR's endpoints.md ("Omit to register a plain Iceberg source with no mapping") and server-integration.md say so. Please align this line with them.
There was a problem hiding this comment.
Good catch, thank you. Aligned it with endpoints.md / server-integration.md: "Without r2rml the source is registered as a plain Iceberg source with no mapping." (2aa8808)
| | Error | Cause | | ||
| |---|---| | ||
| | `… Table not found: Glue table sales.nope not found: …EntityNotFoundException…` | No such Glue database or table in this catalog and region. Check the `<database>.<table>` name, `--region`, and (for another account's catalog) `--catalog-id`. | | ||
| | ``… Glue table sales.t is not an Iceberg table (table_type=EXTERNAL_TABLE): it has no `metadata_location` parameter`` | The Glue table is a Hive / Parquet table, not an Iceberg one. Only tables that carry `metadata_location` can be mapped; catalog browse lists only those. | |
There was a problem hiding this comment.
The (table_type=EXTERNAL_TABLE) part can't appear. glue_metadata_location reads table_type from the Parameters map, which a Hive table normally doesn't have, not from Glue's TableType field. The moto run prints Glue table glue_it.hive_table is not an Iceberg table: it has no \metadata_location` parameter`. Please drop the parenthetical.
There was a problem hiding this comment.
Yep. glue_metadata_location only prints table_type when it's in the table's Parameters, which a Hive table normally doesn't carry, so the common case is exactly what the moto run prints. Dropped the parenthetical (2aa8808).
| match failure { | ||
| SdkFailure::NotFound => IcebergError::TableNotFound(format!("{what} not found: {detail}")), | ||
| // `load_table` renames `table` to the table identifier (`name_denied_table`). | ||
| SdkFailure::AccessDenied => IcebergError::CatalogAccessDenied { |
There was a problem hiding this comment.
Minor: detail is the full SDK chain, and on the server it reaches query clients verbatim in the 403. A Glue AccessDenied message usually includes User: arn:aws:sts::<account>:assumed-role/<role>/… is not authorized to perform glue:GetTable on arn:aws:glue:…, so any querying client learns the server's role ARN and account id. StorageAccessDenied already behaves this way, so this isn't new. Worth considering a shorter message on the query path and the full chain only in logs.
There was a problem hiding this comment.
Agreed it was worth doing now, and since StorageAccessDenied has the same leak I fixed it at the query-path lifter rather than in the SDK client, so it covers the whole class (0e1c06c). storage_query_error now runs both StorageAccessDenied and CatalogAccessDenied through query_safe_denial, which swaps each arn:aws… token (any partition) for arn:<redacted>, keeps AWS's reason ("…is not authorized to perform: glue:GetTable … because no identity-based policy allows…"), and logs the full text at warn. That covers every catalog mode (REST, Glue, S3 Tables) and storage, and Delta's Unity denial goes through the same helper.
I went with redacting the identity rather than a shorter message, since the reason is the part whoever's debugging the query actually needs, but happy to go terser if you'd rather. The onboarding / verify path (storage_api_error) deliberately keeps the full text: it's admin-facing, and solo classifies verify failures by that wording, so redacting there would've been a solo-visible change. query_denials_redact_aws_identities_but_keep_the_reason pins both halves, and errors.md documents it.
| ty("ex:Row"), | ||
| ) | ||
| .await, | ||
| Err("Table not found"), |
There was a problem hiding this comment.
Small tightening: "Table not found" would also match a not-found from another lane. Asserting "Glue table glue_it.no_such_table not found", which only the Glue client produces, pins that the error came from GetTable.
There was a problem hiding this comment.
Tightened to Glue table glue_it.no_such_table not found (c188806). The new S3 Tables missing-table check asserts S3 Tables table glue_it.no_such_table not found the same way; changing that wording in the client fails it.
| meta.catalog_uri = Some(cfg.catalog.catalog_label().to_string()); | ||
| } | ||
| } | ||
| let id = cfg.table.identifier(); |
There was a problem hiding this comment.
Minor: for a mapping-defined source, cfg.table is the default.default placeholder (config.rs), so /info lists a phantom default.default table and each /info makes a GetTable / loadTable call for it that always fails (logged at debug). This already happened for REST via CLI/server. It now also reaches Glue, S3 Tables and Python REST sources. Skipping the placeholder here would fix it.
There was a problem hiding this comment.
Fixed in 1cf4520. The placeholder is one named constant now (fluree_db_iceberg::config::MAPPING_DEFINED_TABLE), which the mode parser records and /info skips for a mapped source, so no phantom row and no doomed GetTable / loadTable on every /info. The moto test's /info check now asserts tables == ["glue_it.customers"], which fails if the skip is removed.
| mapping: R2rmlMappingInput::Content(common.mapping), | ||
| mapping_media_type: None, | ||
| }; | ||
| let rest = spec.catalog_uri.is_some(); |
There was a problem hiding this comment.
Minor: warehouse, auth and vended_credentials are applied only in REST mode, so passing them with glue= / s3_tables= is silently ignored. The CLI and server ignore the matching flags the same way. Raising an error (or at least warning) when they're set for a non-REST mode would save someone wondering why their auth did nothing.
There was a problem hiding this comment.
Agreed, and since the CLI and server dropped the same settings silently, I fixed it in the shared mode parser rather than in Python alone (fea526c). CatalogModeArgs now carries the REST-only settings a surface was given (rest_only), and from_mode refuses them in direct / glue / s3tables with <setting> applies to rest mode only; glue mode would ignore it, the setting spelled the way that surface spells it (--auth-bearer, auth_bearer, auth). That covers the CLI's bearer / OAuth2 / --warehouse flags, both server request shapes (Google metadata auth too, on the map route), and Python's warehouse / auth / vended_credentials.
For Python I made vended_credentials default to None so only an explicit True is refused: False agrees with every mode (and --no-vended-credentials on the CLI stays accepted for the same reason). Each surface builds its own list, so each surface's test drives every one of its settings through (88279cf); a field dropped from a list fails it.
This is a behavior change (an error where we used to silently ignore), so flagging it, but I went with an error over a warning since there's no case where the ignored setting does anything.
| @@ -184,6 +184,36 @@ impl IcebergGsConfig { | |||
| } | |||
|
|
|||
| /// Validate the configuration. | |||
There was a problem hiding this comment.
Nit: /// Validate the configuration. now sits on top of validate_aws_sdk_catalog, so pub fn validate below has no doc comment.
There was a problem hiding this comment.
Moved back onto pub fn validate (126b248), thanks.
| use async_trait::async_trait; | ||
| use std::collections::HashMap; | ||
|
|
||
| /// Response from loading a table, including optional vended credentials. |
There was a problem hiding this comment.
Nit: same thing here. /// Response from loading a table… now documents name_denied_table instead of LoadTableResponse.
There was a problem hiding this comment.
Same fix, back on LoadTableResponse (126b248).
The Glue/S3 Tables helpers were inserted between `LoadTableResponse` and `IcebergGsConfig::validate` and their doc comments, so each comment had merged into the new helper's. Each is back on its own item.
A rest/glue/s3tables source whose tables all come from its R2RML mapping records `default.default` as its own table, to satisfy the `namespace.table` shape. `/info` listed it (and asked the catalog about it) next to the mapping's real tables. The placeholder is now named once, `fluree_db_iceberg::config::MAPPING_DEFINED_TABLE`, and `/info` skips it for a mapped source.
…n settings When a REST loadTable reply carried a matching `storage-credentials` entry, the entry's config replaced the reply's top-level `config` wholesale, so the table's region, endpoint and path-style settings were lost and reads went to the default endpoint. The entry now layers over the top-level map: connection settings come from `config` unless the entry overrides them, and credential keys come only from the entry (a remote-signing entry still yields no credentials, so §2 refuses rather than reusing top-level keys the catalog did not scope to this table).
Glue reports an expired session, an unknown access key or a bad signature as HTTP 400 error codes (`ExpiredTokenException`, `UnrecognizedClientException`, `InvalidSignatureException`), so they fell through to a generic catalog error. They are refusals of the caller's identity, so they now classify as `CatalogAccessDenied` (err:catalog/AccessDenied, 403), the same as `AccessDeniedException`.
…urce config The cross-query loadTable cache (60s) and the disk pointer (300s, across processes) were keyed by graph-source id + namespace + table only. Neither is invalidated on drop, so a source dropped and re-created under the same name against another catalog (URI, region, Glue catalog id, S3 Tables bucket) could read the old catalog's table until the entry expired. Both now key on the source config's fingerprint as well; the per-query session pin stays on the bare key, since one query sees one config.
AWS phrases a denial as `User: arn:aws:sts::<account>:assumed-role/<role>/... is not authorized to perform: ... because ...`. The query path passed that text straight into err:catalog/AccessDenied and err:storage/AccessDenied, so any client able to query a source learned the server's role and account. On the query path (Iceberg storage and catalog denials for every catalog mode, and Delta's Unity denial) ARNs are now replaced with `arn:<redacted>`, the reason is kept, and the full text is logged. The onboarding and verify path (`storage_api_error`) is unchanged: it is admin-facing, and hosts classify verify failures by its text.
A REST catalog's auth (bearer, OAuth2 and, on the server, Google metadata auth), its warehouse, and a request for vended credentials mean nothing to direct, glue or s3tables mode, which dropped them silently: a user who passed `--auth-bearer` with `--mode glue` got a source that ignored it. The shared mode parser (`CatalogModeArgs::rest_only`) now refuses them with `<setting> applies to rest mode only; <mode> mode would ignore it`, on every surface: the CLI's flags, both server request shapes, and Python's `map_iceberg` (whose `vended_credentials` now defaults to None so that turning vending off, which agrees with every mode, is still accepted).
The moto CI test covered Glue only, so the s3tables mode had no test that ran in CI. moto mocks S3 Tables too: the test now creates a table bucket, namespace and table there, copies the fixture's customers metadata into the table's warehouse bucket, points the table at it with UpdateTableMetadataLocation, and reads it through the engine's own GetTableMetadataLocation (50 rows), checks a missing table's error, browses the bucket, and checks `/info` lists the mapping's table and not the mapping-defined placeholder. The Glue missing-table check now asserts the `Glue table ... not found` wording rather than any error.
…ml does - The disk pointer's `FLUREE_ICEBERG_LOADTABLE_PTR_TTL_SECS` (300 s) was undocumented, and the freshness note named the 60 s in-memory TTL as the only freshness knob. Both are listed, with what each window means for a dropped table or revoked catalog access, and for Glue and S3 Tables, which are not asked again for the whole disk window. - Omitting `r2rml` registers a plain Iceberg source; it does not auto-generate a mapping. - The Glue not-an-Iceberg-table error no longer quotes a `table_type` it does not print.
moto does not refuse a call, so the moto CI test cannot show how a real denial is classified. A wiremock endpoint now answers the SDK clients with AWS's own error shapes: Glue's HTTP 400 codes (`AccessDeniedException` with the service's `:http://...` suffix, and the expired / unknown / badly-signed credential codes) and S3 Tables' 403 `ForbiddenException` / `AccessDeniedException` must reach `load_table`'s caller as `CatalogAccessDenied` naming the table; Glue's `EntityNotFoundException` and S3 Tables' 404 `NotFoundException` as `TableNotFound`.
The server and Python tests refused one REST-only setting each, so a field dropped from a surface's list would go unnoticed (each surface builds its own list from its own request shape). The server test now sends every field on both request shapes (the map route's eleven, Google metadata auth included, and the browse/preview connection's nine); Python's covers `warehouse` and the `s3_tables=` arm too. The CLI's already drives all nine flags.
|
Thanks for the careful second pass, @bplatz! I agreed with all of it, so it's all folded in here rather than filed: pushed as fast-forwards
Two of the fixes went a bit broader than the comment they answer, so flagging them in case you'd rather they be narrower: the ARN redaction covers every query-path denial (all catalog modes, storage, and Delta's Unity denial), not just the Glue catalog message; and the REST-only refusal is on every surface, so Verification, fwiw: fmt + clippy |
Summary
Adds two native-AWS-SDK catalog modes to the Iceberg/R2RML graph-source path — AWS Glue Data Catalog (
--mode glue) and AWS S3 Tables (--mode s3tables) — so tables written through Glue (Athena, Spark, Trino, pyiceberg, …) can be read without aversion-hint.textand without a REST catalog in front of them.# mapping-driven: each rr:tableName is a Glue <database>.<table> fluree iceberg map sales --mode glue --region us-east-1 --r2rml mappings/sales.ttl fluree iceberg map sales --mode s3tables --table-bucket-arn arn:aws:s3tables:us-east-1:123456789012:bucket/analytics --r2rml mappings/sales.ttlToday neither existing mode can read these tables: REST mode has no SigV4, which Glue's Iceberg REST endpoint requires, and Direct mode needs
metadata/version-hint.text, which Glue-catalogued tables don't have (and Direct's listing fallback isn't implemented for S3 —S3IcebergStoragehaslist_dirbut nolist_files).Approach
Both modes resolve the table's current
metadata_locationthrough the native AWS SDK (aws-sdk-glueGetTable/aws-sdk-s3tablesGetTableMetadataLocation), and then the existing reader reads metadata, manifests and data from S3 with the ambient AWS credential chain. No hand-rolled SigV4, no request signing, no REST prefix — the SDK signs its own calls, and the standard AWS endpoint overrides (AWS_ENDPOINT_URL_GLUE,AWS_ENDPOINT_URL_S3TABLES, …) reach private endpoints and local mocks. The Glue pointer is authoritative, so an uncommitted or orphaned metadata file sitting next to the committed one is never read.SDK-native rather than REST + SigV4 because, for a normally S3-authorized principal, neither Glue (IAM mode) nor S3 Tables vends credentials, so ambient reads suffice — and staying on the SDK keeps one signing/transport/credential path instead of a second, hand-rolled one. (I did weigh this again against
mainas it is today, since BigLake landed as anAuthConfigon REST — see the update comment; the SDK-native shape still seems right for this PR, with REST + SigV4 maybe the natural vehicle for Lake Formation vending in #1456.)How it fits
main(after the merge-up)Glue and S3 Tables are catalog modes of the Iceberg source, and they go through the same machinery REST does rather than a parallel copy of it:
loadTableladder for every catalog (per-query snapshot pin, cross-query cache, the disk pointer rung, the deferredLazyS3Storage, the time-pin guard, the §2 fail-closed storage decision) —resolve_catalog_load_and_storage/catalog_session_storageoverArc<dyn SendCatalogClient>. The two caches that outlive a query (cross-query and disk pointer) are keyed by the source's config too, so a source re-created under the same name against another catalog never answers from the old one's entry.R2rmlCache::catalog_clients), so SDK clients aren't rebuilt per cache miss. A disk-pointer hit on a non-vending catalog builds its ambient storage without calling the catalog at all.catalog_client) behind browse, preview, sample, storage verify, and the provisional R2RML query; metadata is read frommetadata_locationwhen a catalog returns none inline.region, elses3_region, else the SDK chain (S3 Tables: the bucket ARN's region); S3 reads uses3_region, else the catalog's region.IcebergConnectionConfig::from_mode/IcebergCreateConfig::from_mode), and one set of validation rules (CatalogConfig::validate_aws_sdk_catalog) that the API layer delegates to.service error); a missing table isTableNotFound, and a refused catalog call (including Glue's expired / unknown / badly-signed credential codes) iserr:catalog/AccessDenied(403), the same typed error Delta/Unity uses. On the query path, AWS identities (arn:…) in any storage or catalog denial are redacted and the full text logged; onboarding and verify keep the full text.Glue and S3 Tables refuse
vended_credentials = true(as Direct does), refuse a region that isn't an AWS region code (it becomes part of the SDK's hostname), and S3 Tables refuses aregionthat contradicts its bucket ARN. Every mode other than REST refuses REST-only settings (catalog auth,warehouse, a request for vended credentials) on the CLI, server and Python, rather than silently ignoring them. Browse lists only Iceberg tables, across every page.Also in this PR
Glue made a few REST-path gaps visible, and since each would otherwise have become its own issue, they're fixed here too:
err:catalog/AccessDenied(403), the same error Glue/S3 Tables and Delta/Unity raise, naming the table. The message keeps theCatalog request failed (<status>)wording hosts classify verify failures by.prepare_iceberg_scanbuilt REST clients by hand: it never hydratedSecretRefauth (so such a source couldn't be materialized at all), and it skipped the §2 credential decision (so a vended-required source whose catalog vended nothing was read with the process's ambient identity, though queries on it refuse). REST, Glue and S3 Tables now share one arm with the query path's client and storage decision./inforow counts for every catalog, not just REST: Glue/S3 Tables counts come from the metadata file, through the query path's caches. A mapping-defined source's placeholder table (MAPPING_DEFINED_TABLE) is no longer listed.map_iceberg(..., glue=fluree.Glue(region=...))/s3_tables=fluree.S3Tables(arn), through the same mode parser as the CLI and server — which also fixes mapping-driven REST sources (notable) in Python, which failed validation before.storage-credentials(apache/iceberg #10722): RESTloadTablenow parses the standardized top-levelstorage-credentialsarray, ahead of the legacyconfigmap, and the two duplicatedloadTableparse sites are factored into oneparse_load_table_response. The longest matching prefix is final, and its entry layers over the top-levelconfig: connection settings (region, endpoint, path-style) still come fromconfigunless the entry overrides them, while credential keys come only from the entry. So an entry with no static keys (e.g. remote signing) means no credentials, and §2 refuses the read rather than falling back to keys the catalog didn't scope to this table. Not hit by the SDK-native path; it's a latent 403 for any REST catalog that vends this way.Tests
it_iceberg_glue_moto(new, runs in CI): replays a committed Glue-written fixture into moto (a local mock of S3, Glue and S3 Tables) and reads it through the public API — a table viaGetTable(50), the current metadata among three (200), the Glue pointer over an uncommitted00099metadata file (100, not 0), a two-table join from one mapping (200), materialize scans (full / incremental / pinned) and a@snapshot:query,/infocounts and tables, clear errors for a missing table and a Hive table, browse, and preview; and ins3tablesmode, a table resolved viaGetTableMetadataLocation(50), a missing table's error, and browse. Thetestjob gets a pinnedmotoserver/motoservice;glue_moto_is_configured_in_cifails if the job's marker is set without the endpoint, so a skip can't read as a pass.testjob, no moto): a wiremock endpoint serves AWS's own error shapes to the Glue and S3 Tables SDK clients and checks each denial / not-found reaches the caller typed and naming the table.scripts/glue-local/: the CLI-level harness the test came from (moto + pyiceberg'sGlueCatalog, no AWS account, no Docker).check.sh targetgrades aflureebinary;write_fixture.shregenerates the CI fixture.metadata_locationextraction, region resolution and validation, the S3 Tables ARN, mode parsing (including the REST-only refusal on every surface),storage-credentialsprecedence and layering, the config-keyed cache key, and query-path redaction. The live AWS tests (it_glue_live,it_glue_sdk_reads) are#[ignore]d and env-gated, like the other live Iceberg tests.Follow-ups
Follow-up: #1456 — Lake-Formation-vended credentials for LF-governed Glue tables read by a restricted principal (ambient reads 403 there).
Not in this PR (both already filed): #2038 and #2039, the R2RML loader findings the harness turned up. In fluree/solo, once this lands in a release or pin: opening
glue/s3tablesas catalog types, and teaching its verify classifier the Glue catalog-denial wording (today it would read anAccessDeniedExceptionas a storage denial).