Skip to content

feat!: require operation intent for table resolution - #199

Draft
mitchsw wants to merge 7 commits into
den-55from
mitch.ward/operation-aware-catalog
Draft

mitchsw wants to merge 7 commits into
den-55from
mitch.ward/operation-aware-catalog

Conversation

@mitchsw

@mitchsw mitchsw commented Nov 5, 2026 •

Copy link
Copy Markdown

Which issue does this PR close?

Targets this fork's den-55 branch. No upstream issue has been opened.

Rationale for this change

Authorizing catalogs need to distinguish operations to make fine-grained permission decisions. A caller may be allowed to insert into a table without selecting from it, but DataFusion still needs the destination schema to plan the insert. A name-only lookup cannot express that distinction.

Table lookup now requires an operation intent. SQL planning, asynchronous prefetch, and catalog snapshots carry it to the catalog and preserve it in cached lookups. Applications retain control of identity and the mapping from operations to privileges.

What changes are included in this PR?

  • Require TableIntent on existing lookup methods. SchemaProvider::table, AsyncSchemaProvider::table, ContextProvider::get_table_source, and SessionContext::table_provider accept an explicit intent. There are no compatibility overloads or implicit defaults. Wrappers must forward intent; catalogs without authorization can explicitly ignore it.
  • Describe the operations DataFusion supports. The flat enum distinguishes Describe, Read, insert modes, update/delete/truncate, MERGE clause actions, and specific create/drop/index operations. Creation carries or_replace and authorizes the name even when it does not exist. Metadata needed to plan a mutation uses that mutation's intent; DataFusion adds no separate Describe lookup or privilege hierarchy.
  • Preserve intent through planning and caches. INSERT INTO t SELECT * FROM t checks both insert and read intent. Providers and authorized absence are cached by resolved name and intent. Ordinary SELECT lookup counts are unchanged; there is no per-row execution work. ContextProvider::get_table_source now returns an optional source: Ok(None) means authorized absence, while denial and lookup failures remain errors. DDL does not suppress those errors under IF EXISTS or IF NOT EXISTS.
  • Carry intent through optional remote snapshots. resolve_table_references_with_intent supplies (TableReference, TableIntent) pairs to Async*::resolve. Unrequested pairs fail, including names not previously resolved. Snapshots are scoped to one caller and query. Metadata may still be cached independently beneath authorization checks; separate intent lookups need not duplicate metadata fetches.
  • Preserve implicit file queries without swallowing errors. enable_url_table() and CLI file queries remain supported. UrlTableFactory::try_new(url, intent) receives the original intent only after a successful catalog miss. DDL misses do not infer files. The CLI configures stores inside the file factory before inference; catalog denial never enters that path. Missing files and empty listings remain absent, while inference failures propagate. Automatic store registration requires the typed ObjectStoreNotFound registry error; other registry failures stop resolution.

Guided code walk · Catalog integration guide

Resolution paths and integration boundaries
Path Intent handling
Built-in SQL Classifies AST occurrences, prefetches through the catalog, then resolves through an intent-keyed synchronous planner cache.
Direct SqlToRel Calls the required ContextProvider method, including for DDL destinations.
DataFrame APIs SessionContext::table supplies Read; DataFrame::write_table preserves the insert mode.
Table DDL Planning requests the actual command intent; built-in create/drop execution repeats it. CREATE INDEX execution remains application-owned.
Metadata Named DESCRIBE and SHOW COLUMNS/CREATE request Describe. Information-schema columns/views and default table_type request it for underlying objects. DESCRIBE of a query retains its normal read checks.
Remote catalogs Optional Async*::resolve helpers preserve exact intents. Built-in session prefetch does not call these helpers.
Implicit file queries Optional dynamic catalogs preserve intent into the file factory. The CLI installs its own factory around an ordinary catalog, so store setup precedes inference without error-driven retries.
Foreign FFI schema providers The existing ABI cannot convey intent, so the adapter supports Read and rejects other intents. Same-library round trips retain the original provider.

Applications must still enforce the following boundaries:

  • Describe does not automatically filter enumeration. Names, existence checks, and table_type overrides need an application visibility policy; denial during information-schema traversal fails the query. The built-in information-schema provider does not authorize access to the system tables themselves.
  • Mutation methods need their own enforcement, including races between lookup and mutation. Schema/catalog/function commands remain outside this table intent. An approved catalog miss is not file-location authorization: applications enabling implicit files must authorize the location in their factory before path parsing, store setup, or inference, or leave the feature disabled.
  • A returned provider is not restricted to its requested intent. Execution checks remain necessary for provider reuse, revocation, stored/prepared plans, custom planner extensions, and distributed execution.
  • Snapshot keys contain neither caller identity nor policy versions. Snapshot name enumeration includes providers resolved for any intent and is not automatically Describe-filtered. Reusing a snapshot across callers or after permission changes can reuse stale authorization. Metadata enumeration can also need Describe lookups not named directly in the SQL.

Are these changes tested?

Regression coverage includes write-only inserts, denied sources before schema inspection, self-inserts, forwarding wrappers, MERGE actions, Describe, DDL on absent names, DDL revocation, exact-intent snapshots, and implicit-file resolution boundaries. New regressions cover terminal catalog/factory denial, DDL without storage side effects, missing files versus inference failures, registry denial without automatic registration, and implicit Describe/INSERT.

Current revision: workspace Clippy with all targets and features and -D warnings, Rust formatting, and documentation formatting passed. Clippy compiled the regression test code; test execution was skipped as requested.

Historical focused validation passed 684 SQL/catalog tests and 19 core authorization tests. Those are historical results, not a test run of the current revision. Dynamic-file SQL logic, CLI execution, and cross-library FFI checks remain outstanding. Full CI and downstream consumer migration have not been validated.

Are there any user-facing changes?

Yes: breaking Rust APIs and stricter fallback error handling. Existing catalog implementations, planner contexts, callers, and remote snapshot integrations must migrate. ContextProvider::get_table_source additionally changes from a required source to Result<Option<Arc<dyn TableSource>>>. UrlTableFactory::try_new also requires intent. Implicit SQL file queries remain available, while denied catalog lookups and inference failures propagate; DDL targets no longer trigger file inference. Foreign FFI adapters reject non-read intents until the ABI can carry them.

The release notes and migration guide document signature changes, wrapper migration, absence/error semantics, snapshot behavior, factory migration, the typed missing-store error, and error propagation. The PR carries the api change label.

Carry table intent through catalog lookups, SQL planning, and asynchronous
provider caches so applications can authorize writes before schema use.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
@mitchsw mitchsw closed this Nov 5, 2026
@mitchsw
mitchsw deleted the mitch.ward/operation-aware-catalog branch November 5, 2026 20:13
@mitchsw mitchsw changed the title Add operation-aware table resolution for catalog authorization Closed: incorrect repository target Nov 5, 2026
@mitchsw
mitchsw restored the mitch.ward/operation-aware-catalog branch November 5, 2026 20:21
@mitchsw mitchsw reopened this Nov 5, 2026
@mitchsw mitchsw changed the title Closed: incorrect repository target Add operation-aware table resolution for catalog authorization Nov 5, 2026
@mitchsw mitchsw changed the title Add operation-aware table resolution for catalog authorization Pass table access intent through catalog resolution Nov 5, 2026
…ntent

Make access handling explicit across catalogs and planner contexts, keep remote snapshots separated by operation, and document authorization boundaries.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
@mitchsw mitchsw added the api change Changes to the public API label Nov 5, 2026 — with ddtool CLI
@mitchsw mitchsw changed the title Pass table access intent through catalog resolution Require access-aware catalog resolution Nov 5, 2026
mitchsw and others added 2 commits November 5, 2026 22:27
Remove legacy lookup and snapshot adapters, migrate all callers, and document the single-method interfaces.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
Carry create, replace, drop, and index intent through prefetch, direct SQL
planning, and built-in DDL execution. Preserve authorized absence in the
canonical planner API and in remote snapshots; reject unrequested lookups.

Remove dynamic file and object-store catalog wrappers. Keep file access
explicit through registration, external tables, COPY, and DataFrame APIs.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
mitchsw and others added 2 commits November 5, 2026 22:49
Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
Name the operation contract TableIntent and use Describe for named-object
metadata inspection. Preserve intent through lookup, prefetch, and snapshot
APIs, and clarify application-owned visibility and privilege mapping.

Document breaking signatures, authorized absence, snapshot isolation, removed
implicit file lookup, and foreign FFI limits in release and migration notes.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
@mitchsw mitchsw changed the title Require access-aware catalog resolution feat!: require operation intent for table resolution Nov 6, 2026
Restore implicit file queries while keeping catalog denial and storage failures distinct from absence.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-6 <noreply@localhost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant