Skip to content

[core] Allow enabling 'partial-update.remove-record-on-delete' on existing tables - #11656

Merged
JingsongLi merged 1 commit into
apache:masterfrom
wzx140:feat/partial-update-remove-on-delete-alterable
Dec 3, 2026
Merged

JingsongLi merged 1 commit into
apache:masterfrom
wzx140:feat/partial-update-remove-on-delete-alterable

Conversation

@wzx140

@wzx140 wzx140 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Purpose

partial-update.remove-record-on-delete is @Immutable, so a partial-update table that already holds data cannot turn it on. Such a table can only run DELETE FROM by rewriting files, which fails unless the touched files are compacted. This PR allows a one-way change from false to true through ALTER TABLE.

The change is safe for existing data. Without the option, and without ignore-delete or sequence groups, a partial-update table rejects every retraction at merge time, so its data files hold no -D records. Enabling the option only affects records written afterwards.

  • ALTER TABLE: false (or unset) to true is allowed. true to false and UNSET are rejected, because the table may then hold -D records that fail the merge once the option is off. This follows the existing check for ignore-delete.
  • Conflicting options: enabling it together with ignore-delete or sequence groups keeps going through the existing merge function validation, which runs on every schema change.
  • Dynamic options (spark.paimon.*, Flink hints, pypaimon table.copy) cannot change the value. Unlike ignore-delete = true, which drops -D at write time, this option lets a job store -D records. If one job enables it temporarily, the other jobs, which still use the table's value, fail when they merge those records. Values are compared as booleans, so passing the current value is still allowed.
  • CDC: SynchronizationActionBase#alterTableOptions now reloads the table after the ALTER. Before, it copied the old table with the altered options, and that copy checked them as dynamic options against the old schema, so enabling this option through --table_conf committed the ALTER and then failed the job. Every option it passes has been persisted by the ALTER, and the callers pass a table loaded by catalog.getTable, so the reload loses nothing.
  • pypaimon:
    • Mirrors the ALTER check and the dynamic option check.
    • Schema commits now also run the delete option conflict checks of the Java PartialUpdateMergeFunction.Factory, which pypaimon did not do before.

After enabling the option, restart the jobs that read or write the table. A job still running with the previous value fails when it merges a -D record.

Tests

  • SchemaManagerTest: one-way alter and reset checks.
  • DeleteFromTableTestBase (Spark 3.5, V1 and V2 write): enabling the option on a table with uncompacted data and running DELETE, dynamic options that change or keep the value, disabling and UNSET, and conflicts with ignore-delete and sequence groups.
  • pypaimon: the alter check, the conflict checks on create and alter, and dynamic options that change or keep the value.
  • SchemaValidationTest, the full Spark 3.5 DeleteFromTableTest / V2DeleteFromTableTest suites, and the pypaimon schema, table, partial-update and aggregation tests pass.
  • MySqlSyncTableActionITCase#testEnableRemoveRecordOnDeleteInExistingTable covers the CDC fix. I could not run it locally because the MySQL test container was not reachable, so it needs CI. A core-level check confirmed the mechanism: copying the pre-ALTER table is rejected, and reloading returns the new value.

🤖 Generated with Claude Code

…existing tables

- CoreOptions.java, core_configuration.html: drop @immutable from partial-update.remove-record-on-delete and describe the one-way change
- SchemaManagerUtils.java: allow false -> true only and reject true -> false and reset, like ignore-delete; conflicts with ignore-delete and sequence groups stay with the merge function validation
- AbstractFileStoreTable.java: reject changing the option through dynamic options, compared by boolean value, so all jobs see the same value
- SynchronizationActionBase.java: reload the table after ALTER instead of copying the old table, so CDC table conf can enable the option
- schema_manager.py: mirror the one-way check, and mirror the delete option conflict checks of the Java merge function factory on every schema commit
- file_store_table.py, core_options.py: mirror the dynamic option check and the mutability in pypaimon
- SchemaManagerTest.java, DeleteFromTableTestBase.scala, MySqlSyncTableActionITCase.java, schema_manager_test.py, file_store_table_test.py, test_partial_update_e2e.py: cover allowed and rejected changes, dynamic options, conflicts, CDC table conf and a Spark DELETE after enabling
k, oldValue, newValue, tableSchema)) {
// Every reader and writer must agree on it, otherwise -D records written
// by one job make the merge of the others fail.
if (PARTIAL_UPDATE_REMOVE_RECORD_ON_DELETE.key().equals(k)) {

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.

Why not put this check into SchemaManager.checkAlterTableOption?

@JingsongLi
JingsongLi merged commit ef2fc65 into apache:master Dec 3, 2026
54 of 55 checks passed
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.

2 participants