Skip to content

[core][spark] Support collecting format table partition statistics in MSCK REPAIR TABLE - #9297

Merged
JingsongLi merged 1 commit into
apache:masterfrom
sundapeng:upstream/s5-measure-partitions-in-msck
Aug 21, 2026
Merged

[core][spark] Support collecting format table partition statistics in MSCK REPAIR TABLE#9297
JingsongLi merged 1 commit into
apache:masterfrom
sundapeng:upstream/s5-measure-partitions-in-msck

Conversation

@sundapeng

@sundapengsundapeng commented Aug 18, 2026

Copy link
Copy Markdown
Member

Purpose

A commit reports only what it wrote. A format table also holds partitions written by something that
is not Paimon, files deleted out of band, and increments that drifted, and nothing corrects those.
MSCK REPAIR TABLE already reconciles the partition set against the directories, so it is where the
numbers can be reconciled too.

Behind spark.paimon.format-table.repair.collect-statistics, off by default: a plain repair lists
partition directories, while measuring lists the files inside every one of them, a different order of
magnitude on a table with many partitions. spark.paimon.format-table.statistics.parallelism
(8) bounds how many partitions are measured at once.

FormatTablePartitionStatsCollector measures through the same listing the scan uses, so a
measurement counts exactly the files a reader would return and committer staging trees are pruned
rather than walked. It covers every registered partition that has a directory, not only the newly
added ones, and never registers one the repair did not ask for. A measurement is of a whole
partition, so it replaces what the catalog held rather than adding to it, and a partition whose
directory is gone measures as an exact zero on the file numbers. A listing failure aborts the whole
collection rather than write a partial measurement. The row count is not part of this: reading it
means opening every file's footer, which no listing does.

Tests

  • FormatTablePartitionStatsCollectorTest: staging trees, hidden files beside the data, a missing
    directory, the value-only layout and a value the directory name has to escape, alignment with the
    given specs, a spec missing a partition key, and a listing failure aborting both the serial and
    the parallel path.
  • FormatTablePartitionRepairTest: measuring every partition on disk, a repair without ADD
    registering nothing, and a listing failure leaving the catalog untouched.
  • CatalogManagedPartitionMsckRepairTest: the command end to end, with the option off and on.

@sundapengsundapeng changed the title [core][spark] Measure format table partitions in MSCK REPAIR TABLE[wip][core][spark] Measure format table partitions in MSCK REPAIR TABLEAug 18, 2026
@sundapengsundapeng changed the title [wip][core][spark] Measure format table partitions in MSCK REPAIR TABLE[WIP][core][spark] Measure format table partitions in MSCK REPAIR TABLEAug 18, 2026
@sundapeng
sundapengforce-pushed the upstream/s5-measure-partitions-in-msck branch 10 times, most recently from 2d03efe to 69432a4CompareAugust 19, 2026 12:48
@sundapeng
sundapengforce-pushed the upstream/s5-measure-partitions-in-msck branch from 69432a4 to 00290d6CompareAugust 19, 2026 17:26
@JingsongLi
JingsongLi marked this pull request as draft August 20, 2026 01:05
@sundapeng
sundapengforce-pushed the upstream/s5-measure-partitions-in-msck branch 4 times, most recently from fe61d73 to 6a78c95CompareAugust 20, 2026 10:39
@sundapengsundapeng changed the title [WIP][core][spark] Measure format table partitions in MSCK REPAIR TABLE[core][spark] Measure format table partitions in MSCK REPAIR TABLEAug 20, 2026
@sundapeng
sundapeng marked this pull request as ready for review August 20, 2026 11:40
@sundapeng
sundapengforce-pushed the upstream/s5-measure-partitions-in-msck branch from 6a78c95 to 3a252e1CompareAugust 20, 2026 11:44
@sundapengsundapeng changed the title [core][spark] Measure format table partitions in MSCK REPAIR TABLE[core][spark] Collect format table partition statistics in MSCK REPAIR TABLEAug 20, 2026
@sundapengsundapeng changed the title [core][spark] Collect format table partition statistics in MSCK REPAIR TABLE[core][spark] Support collecting format table partition statistics in MSCK REPAIR TABLEAug 20, 2026
… MSCK REPAIR TABLE
A commit reports what it wrote. Nothing reports what is already there, and for a
format table plenty is: partitions written by something that is not Paimon, files
deleted out of band, an increment redelivered and counted twice. MSCK REPAIR
TABLE is already the command that reconciles the partition set against the
directories, so it is the natural place to reconcile the numbers too.
Off by default, behind spark.paimon.format-table.repair.collect-statistics,
because measuring changes what a repair costs: the plain diff lists partition
directories, and measuring lists the files inside every one of them. That is a
different order of magnitude on a table with many partitions, and a repair should
not silently become that. When it is on, spark.paimon.format-table.statistics.parallelism
caps how many partitions are measured at once, at 8: listing one is a round trip
the driver spends waiting on, and the cap keeps a table with many partitions from
turning that wait into a burst of requests.
When on it measures every partition that ends up registered with a directory
behind it, not only the ones it just added — the stale numbers of partitions
written outside Paimon are exactly what a repair exists to correct. Without ADD it
stays inside the already-registered set, so measuring never registers a partition
the command was not asked to.
The collector reports what a reader would see. File count, byte size and last file
creation time come from the listing. It stops there. The row count it leaves
unknown: reading it means opening every file's footer, which no listing does and
which the command that wants exact rows can pay for on its own. A listing failure
aborts the whole collection rather than reporting what it managed to see, because
a truncated listing is indistinguishable from a partition that lost files. A
partition whose directory is gone measures as an exact zero, with no last file to
date.
Tests: FormatTablePartitionStatsCollectorTest covers staging trees, hidden files
beside the data, a missing directory, the value-only layout and a value the
directory name has to escape, alignment with the given specs, a spec missing a
partition key, and a listing failure aborting both the serial and the parallel
path. FormatTablePartitionRepairTest covers measuring every partition on disk, a
repair without ADD registering nothing, and a listing failure leaving the catalog
untouched. CatalogManagedPartitionMsckRepairTest covers the command end to end,
with the option off and on.
@sundapeng
sundapengforce-pushed the upstream/s5-measure-partitions-in-msck branch from 3a252e1 to e76a378CompareAugust 20, 2026 11:49

@JingsongLiJingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@JingsongLi
JingsongLi merged commit 2ce5cea into apache:masterAug 21, 2026
14 checks passed
Sign up for freeto 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.

2 participants

@sundapeng@JingsongLi