Skip to content

[spark] Cover the partition operations left over on format tables - #9119

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

[spark] Cover the partition operations left over on format tables#9119
sundapeng wants to merge 1 commit into
apache:masterfrom
sundapeng:upstream/s7-format-table-partition-operations

Conversation

@sundapeng

Copy link
Copy Markdown
Member

Purpose

TRUNCATE TABLE, TRUNCATE TABLE PARTITION and ALTER TABLE ... RENAME TO PARTITION all refuse a
format table with catalog-managed partitions. 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 one behaviour change is an error message. 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 names the operations that do manage those partitions.

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

Tests

New: CatalogManagedPartitionEdgeParityTest, CatalogManagedPartitionDdlParityTest.

The probes are mapped from Spark's own TruncateTableSuiteBase,
AlterTableRenamePartitionSuiteBase, AlterTableAddPartitionSuiteBase,
AlterTableDropPartitionSuiteBase and ShowPartitionsSuiteBase, so the reference for "what should
happen" is Spark's rather than ours.

One finding recorded rather than worked around: SHOW PARTITIONS prints a null partition value as
dt=null rather than the default partition name. That is Spark's own ShowPartitionsExec with a v2
table, and a native Paimon partitioned table prints the same thing — so a test pins where the
behaviour comes from instead of special-casing it here.

API and Format

No public API change. No format change.

Documentation

None needed; the only user-visible change is an error message.

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