[spark] Add managed Format Table partition administration#8730
Closed
sundapeng wants to merge 3 commits into
Closed
[spark] Add managed Format Table partition administration#8730sundapeng wants to merge 3 commits into
sundapeng wants to merge 3 commits into
Conversation
3 tasks
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.
Add list_format_table_partitions and sync_format_table_metadata procedures for catalog-managed Format Tables. Listing pages through the catalog and embeds a filter fingerprint in page tokens so stale cursors are rejected. The sync procedure diffs the filesystem against the catalog registration, defaults to dry-run, and applies repair diffs in bounded batches. MSCK REPAIR TABLE reuses the same sync engine through an interception ahead of Spark's v2 rejection, and SHOW PARTITIONS runs through a bounded, paginated executor.
sundapeng
force-pushed
the
split-v4/format-table-managed-spark-admin
branch
from
July 19, 2026 11:43
c3ad3ad to
02eebd0
Compare
JingsongLi
reviewed
Jul 20, 2026
| `MSCK REPAIR TABLE` fail with an error. | ||
|
|
||
| `SHOW PARTITIONS` throws an error when the number of partitions exceeds | ||
| `spark.paimon.format-table.show-partitions.max-results` (default: 10000). For larger tables, use |
JingsongLi
reviewed
Jul 20, 2026
| remove the option, use `ALTER TABLE my_table UNSET TBLPROPERTIES ('metastore.partitioned-table')`. | ||
| On a REST catalog, an existing Format Table whose partitions were never registered reads as empty | ||
| until you register them with `MSCK REPAIR TABLE my_table` or | ||
| `CALL sys.sync_format_table_metadata`. |
JingsongLi
reviewed
Jul 20, 2026
| * catalog, or {@code null} if they can. | ||
| */ | ||
| @Nullable | ||
| private static String managedFormatTableLoadProblem( |
Contributor
There was a problem hiding this comment.
Just throw exception, remove this.
JingsongLi
reviewed
Jul 20, 2026
| // Keyed by identifier full name: listings themselves live in per-instance caches, so sharing | ||
| // a generation counter across table incarnations (or across catalogs using the same name) can | ||
| // only cause an extra invalidation, never a stale read. | ||
| private static final Cache<String, AtomicLong> GENERATIONS = |
Contributor
There was a problem hiding this comment.
Remove this and all cache.
JingsongLi
reviewed
Jul 20, 2026
| // after deserialization. | ||
| @Nullable private transient Catalog catalog; | ||
|
|
||
| public FormatTableCatalogProvider(Identifier identifier, CatalogLoader catalogLoader) { |
Contributor
There was a problem hiding this comment.
Just use CatalogLoader, remove this FormatTableCatalogProvider.
JingsongLi
reviewed
Jul 20, 2026
| null); | ||
| } | ||
|
|
||
| public FormatTableCommit( |
Contributor
There was a problem hiding this comment.
Remove old constructor.
JingsongLi
reviewed
Jul 20, 2026
| } | ||
| } | ||
|
|
||
| private RuntimeException partitionRegistrationFailure(RuntimeException cause) { |
This was referenced Jul 20, 2026
Member
Author
|
Closing in favour of a re-split of this work. The implementation changed enough since this split that updating the branch in
The review comments here are all addressed; the new PRs describe how. Replaced by: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relationship
Third part of splitting #8713; stacked on the DDL part #8729 (the diff shown here includes the
two previous commits until they merge — please review only the
[spark] Add managed Format Table partition administrationcommit). Marked draft until the DDL part lands.Purpose
Administration and repair on top of the DDL part: two procedures,
MSCK REPAIR TABLEand
SHOW PARTITIONS.Main changes
sys.list_format_table_partitions(table, where?, limit?, page_token?): paged listing.The continuation token is the catalog's own page token, passed through verbatim. With
a
wherefilter, each call returns the matching rows of raw catalog pages, skippingahead past fully-filtered pages so an empty result always means the listing is
exhausted; filtered pages can carry fewer than
limitrows.sys.sync_format_table_metadata(table, mode=ADD|DROP|SYNC, dry_run):filesystem-to-catalog reconciliation.
dry_rundefaults to true; discovery usesraw directory values (round-trips with writer-registered values) and fails on a
mid-scan listing error instead of producing a truncated diff (a DROP diff from a
truncated listing would unregister live partitions). Applies diffs in bounded batches;
both directions converge on rerun. Spark cache is refreshed after any non-preview
attempt, including ambiguous failures.
MSCK REPAIR TABLE [ADD|DROP|SYNC] PARTITIONSreuses the sync engine (bare MSCK =ADD, Hive semantics; DROP is metadata-only). Unmanaged Format Tables and native
Paimon tables keep Spark's rejection.
SHOW PARTITIONSbacked by the catalog, capped with a pointer to the paged procedure.Behavior notes
This first version keeps the procedure surface minimal on purpose: no
scoperestriction and no
targetparameter on the sync procedure (it always reconciles allpartition metadata, exactly like MSCK), and filtered listing pages are allowed to be
sparse instead of maintaining a resumable dense-page cursor. Both can be added later
without breaking the contract.
Tests
Procedure suite (26), MSCK end-to-end against a mock REST server (10), planning suite
extension (23), SHOW partitions exec tests (6).