Skip to content

[spark] Support managed Format Table partition DDL - #8729

Closed
sundapeng wants to merge 2 commits into
apache:masterfrom
sundapeng:split-v4/format-table-managed-spark-ddl
Closed

[spark] Support managed Format Table partition DDL#8729
sundapeng wants to merge 2 commits into
apache:masterfrom
sundapeng:split-v4/format-table-managed-spark-ddl

Conversation

@sundapeng

@sundapeng sundapeng commented Jul 19, 2026

Copy link
Copy Markdown
Member

Relationship

Second part of splitting #8713; stacked on the core part #8728 (the diff shown here includes
the core commit until that PR merges — please review only the [spark] Support managed Format Table partition DDL commit). Marked draft until the core part lands.

Purpose

Spark SQL partition DDL for managed Format Tables on top of the core part:
ALTER TABLE ... ADD/DROP PARTITION backed by the catalog.

Main changes

  • A partition gateway (FormatTablePartitionCatalog) wired into PaimonFormatTable;
    DDL executes against the catalog, not the filesystem.
  • ADD registers then creates the partition directory (empty partitions are immediately
    visible and writable). Partition values are validated against path escapes
    (./.., resolved path must stay under the table root); ADD ... LOCATION is
    rejected (managed table locations are derived).
  • DROP unregisters first, then deletes the directory (the service never deletes data);
    a full spec that is not registered fails without touching its directory (protects
    data awaiting registration). Partial specs expand through the catalog to leaf
    partitions; expansions and unregistrations run in bounded batches.
  • Strict-ADD atomicity (reject the whole batch if any partition exists) is enforced by
    the catalog service — the client forwards IF NOT EXISTS unchanged and skips Spark's
    client-side existence precheck.
  • Session-level metastore.partitioned-table overrides are ignored with a WARN (the
    persisted table property wins) instead of failing table loads.

Tests

DDL planning with a fault-injection catalog (26), partition management round-trips (20),
gateway contract tests incl. mutation batching (6), option handling (5). Partial-spec DROP expansion lists partitions unfiltered and matches client-side — no server-side prefix pushdown in this first version.

Route managed Format Table partition discovery through the catalog so
scans read exactly the registered partitions and an empty registration
reads as empty instead of falling back to directory listing. Validate
partition locations against the table path before any read or delete.
Register written partitions at commit time in bounded batches, keep
IF NOT EXISTS registration idempotent for concurrent writers, and fall
back to unmanaged directory discovery when no catalog manages the
table.
Route ALTER TABLE ADD/DROP PARTITION for catalog-managed Format Tables
through a Spark-side partition gateway. ADD forwards the whole batch
with the IF NOT EXISTS flag so the catalog can apply it atomically and
creates partition directories; strict batch atomicity stays with the
catalog service. DROP unregisters partitions before deleting their
directories, expands partial specs through bounded catalog pagination,
and never touches data that is not registered. Session-level overrides
of the managed flag are ignored when classifying tables, and unmanaged
Format Tables fail with an explicit unsupported error.
@sundapeng

Copy link
Copy Markdown
Member Author

Closing in favour of a re-split of this work.

The implementation changed enough since this split that updating the branch in
place would replace every line and leave the review comments pointing at code
that no longer exists:

  • the serializable provider with its 30s listing cache and JVM-wide generation
    counter is gone, replaced by a partition manager that creates one catalog per
    operation and closes it;
  • the managed scan subclass is gone, folded into FormatTableScan;
  • the two procedures are gone; MSCK REPAIR TABLE is the only entry point;
  • the feature no longer reuses metastore.partitioned-table. It has its own
    option, format-table.partition-source = filesystem | rest, so a
    catalog-level default set for Paimon tables cannot turn it on for a Format
    Table by accident.

The review comments here are all addressed; the new PRs describe how.

Replaced by:

@sundapeng sundapeng closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant