paimon icon indicating copy to clipboard operation
paimon copied to clipboard

[Bug] Flink compact_database uses ordinary append compaction for Data Evolution tables

Open tzphh opened this issue 2 months ago • 0 comments

Search before asking

  • [x] I searched in the issues and found nothing similar.

Paimon version

2.0.0

Compute Engine

Flink 1.19.3 (downstream build), Java 17

Minimal reproduce step

  1. Create an append-only table with a NOT NULL column and Data Evolution enabled:
CREATE TABLE test_db.t (
    id BYTES NOT NULL,
    feature STRING
) WITH (
    'bucket' = '-1',
    'file.format' = 'parquet',
    'row-tracking.enabled' = 'true',
    'data-evolution.enabled' = 'true'
);
  1. Write complete rows, then use the Data Evolution partial-column writer to update only feature for the same row IDs. The update files contain only feature; id remains in the base files. This is not an ordinary INSERT that omits id.

  2. Run database compaction in batch/divided mode:

SET 'execution.runtime-mode' = 'batch';

CALL sys.compact_database(
    including_databases => 'test_db',
    mode => 'divided',
    including_tables => 'test_db[.]t'
);

Compaction takes the ordinary Append path and fails because the partial-column files do not contain the NOT NULL column.

What doesn't meet your expectations?

Expected behavior

Database compaction should use the Data Evolution compaction path, merging partial-column files by row ID before writing complete rows.

Actual behavior

Compaction uses AppendCompactTask / BaseAppendFileStoreWrite.compactRewrite instead.

The partial-column Parquet file does not contain a NOT NULL column that is stored in the base file. The ordinary Append compaction path does not merge these files by row ID, and rewriting fails with the following error (column name replaced with id):

java.lang.IllegalArgumentException:
Field 'id' expected not null but found null value.
    at ParquetRowDataWriter$RowWriter.write(...)
    at BaseAppendFileStoreWrite.compactRewrite(...)
    at AppendCompactTask.doCompact(...)

Local verification

With paimon-bundle:2.0.0, the ordinary Append compaction task fails earlier during reading:

Required column is missing in data file. Col: [id]

The dedicated DataEvolutionNormalCompactTask succeeds and preserves the original non-null IDs and updated values.

The production and local failures occur at different stages, but both involve the ordinary Append compaction path.

Anything else?

Possible cause

In divided mode, CompactDatabaseAction routes BUCKET_UNAWARE tables to AppendTableCompact without checking dataEvolutionEnabled().

Data Evolution tables also use this bucket mode, so they enter the ordinary Append compaction path. That path reads files separately instead of merging partial-column files by row ID.

Single-table CompactAction already checks dataEvolutionEnabled() and selects the dedicated compactor.

Relevant code:

Suggested fix

Use DataEvolutionTableCompact for Data Evolution tables in batch/divided mode.

Combined mode should also be handled explicitly to prevent Data Evolution tables from entering the ordinary Append compaction path.

Regression test

Write complete rows containing a NOT NULL column, then update only another column through Data Evolution. Verify that compaction succeeds and preserves the row count, original non-null IDs, and updated values.

Are you willing to submit a PR?

  • [x] I'm willing to submit a PR!

tzphh avatar Sep 22 '26 10:09 tzphh