Skip to content

[spark] Add tests for catalog-managed Format Table partitions - #9119

Open
sundapeng wants to merge 5 commits into
apache:masterfrom
sundapeng:upstream/s7-format-table-partition-operations
Open

[spark] Add tests for catalog-managed Format Table partitions#9119
sundapeng wants to merge 5 commits into
apache:masterfrom
sundapeng:upstream/s7-format-table-partition-operations

Conversation

@sundapeng

@sundapeng sundapeng commented Aug 9, 2026

Copy link
Copy Markdown
Member

Purpose

A catalog-managed Format Table keeps the visible partition set in the catalog while the rows remain
in partition directories. A partition command must therefore update both sides consistently, or
leave both unchanged.

ADD PARTITION, DROP PARTITION, SHOW PARTITIONS, writes, and MSCK REPAIR TABLE already support
this table type. This PR adds end-to-end coverage for their Spark SQL behavior, including duplicate
ADD handling, DROP IF EXISTS, partial partition specs, case-insensitive column resolution,
writer-side registration, a registered partition whose directory is missing, and default partition
values.

TRUNCATE TABLE, TRUNCATE TABLE PARTITION, and RENAME PARTITION are currently unsupported for a
Format Table. This PR does not add that support. A rejected command must leave catalog registrations
and rows unchanged. If support is added later, TRUNCATE must keep registrations consistent with the
remaining rows, and RENAME must move the registration and directory together without losing rows.

The only production behavior change is the error for an unsupported partition operation. The old
message, Only FileStoreTable supports partitions, is misleading because the Format Table is
partitioned. The new message says that the operation is limited to a native Paimon table and points
Format Table users to ADD PARTITION, DROP PARTITION, and MSCK REPAIR TABLE.

SHOW PARTITIONS renders a null value as dt=null on Spark's V2 path; a native Paimon table has the
same behavior, so this PR records it instead of adding Format Table-specific rendering. Empty string
partition values follow Paimon's existing default-partition encoding and read back as null.

There is no public API, REST contract, or storage format change. ANALYZE TABLE is out of scope.

Tests

  • DDL integration suite: 7/7 passed. Covers ADD / DROP behavior, prefix DROP,
    case-insensitive partition columns, sorted and filtered SHOW output, writer registration, and a
    registered partition whose directory is missing.
  • Partition edge-case integration suite: 9/9 passed. Covers TRUNCATE / RENAME either completing
    consistently or leaving state unchanged, null and empty values, default-partition MSCK discovery,
    and default-partition DROP.
  • Local Spark 3.5 / Scala 2.12 module tests: 66/66 Java tests passed in each focused run; Checkstyle,
    Spotless, and Enforcer passed.

TRUNCATE TABLE, TRUNCATE TABLE PARTITION and ALTER TABLE ... RENAME TO PARTITION
all refuse a format table with catalog-managed partitions, and these tests pin
that they refuse without moving anything: a registration pointing at a directory
that is gone, or data under a spec nobody registered, would both be worse than
the refusal.

The refusal TRUNCATE PARTITION produced described the table wrongly. "Only
FileStoreTable supports partitions" is reached by a table that has partitions and
lists them through this very trait, which sends the reader looking for the wrong
problem; it now says which operations do manage those partitions.

A null partition value registers under the default partition name, keeps a
directory of that name, reads back as null, is discovered by MSCK REPAIR and is
dropped by that name. SHOW PARTITIONS prints it as dt=null rather than the
default name, which is what Spark's own ShowPartitionsExec does with a null
value; a native Paimon table prints the same thing, so the test records where
that behaviour comes from instead of working around it here.

The remaining probes cover ADD/DROP PARTITION idempotence, prefix DROP, partial
specs in SHOW PARTITIONS, case-insensitive partition column names and empty
string partition values, all of which already behaved this way.
@JingsongLi

Copy link
Copy Markdown
Contributor

CI failed

@sundapeng

sundapeng commented Aug 11, 2026

Copy link
Copy Markdown
Member Author

Local Spark 3.5 / Scala 2.12 evidence:

  • before: 9 of 10 Scala tests passed; only the ANALYZE case failed with NOT_SUPPORTED_COMMAND_FOR_V2_TABLE
  • after: 9 of 9 Scala tests and 66 of 66 Java tests passed

Fix: 22e5269.

@sundapeng sundapeng changed the title [spark] Cover the partition operations left over on format tables [spark][test] Add tests for catalog-managed Format Table partitions Aug 11, 2026
@sundapeng sundapeng changed the title [spark][test] Add tests for catalog-managed Format Table partitions [spark] Add tests for catalog-managed Format Table partitions Aug 11, 2026

@leaves12138 leaves12138 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.

Thanks for adding this coverage. I found two issues that should be addressed before merging.

@leaves12138 leaves12138 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.

LGTM. Thanks for addressing the comments.

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.

3 participants