Skip to content

[flink] Support compact_chain_table procedure#8508

Merged
JingsongLi merged 2 commits into
apache:masterfrom
juntaozhang:pr-add-flink-chain-compaction
Jul 10, 2026
Merged

[flink] Support compact_chain_table procedure#8508
JingsongLi merged 2 commits into
apache:masterfrom
juntaozhang:pr-add-flink-chain-compaction

Conversation

@juntaozhang

Copy link
Copy Markdown
Contributor

Purpose

see #8503

Tests

  • CompactChainTableActionITCase.java
  • CompactChainTableProcedureITCase.java

@JingsongLi

Copy link
Copy Markdown
Contributor

compact_chain_table(..., partial partition, overwrite=true) may cause data loss. Using the partial partitionSpec in sinkBuilder.overwrite(partitionSpec) will delete all groups under the specified partial partition in the snapshot branch. However, the source side's skipPreloadTargetSnapshot only generates output from target chain partitions present in the delta. If a snapshot group already exists but has no corresponding delta in the target chain partition, it will be overwritten and deleted without being rewritten. The author is advised to add a scenario: partitioned by (region, dt, hr), chain keys (dt, hr), with a snapshot containing region=FR, dt=..., hr=..., and a delta only including region=CN, dt=..., hr=.... After executing compact_chain_table('dt=..., hr=...', true), the FR data should not be lost.

@juntaozhang

Copy link
Copy Markdown
Contributor Author

compact_chain_table(..., partial partition, overwrite=true) may cause data loss. Using the partial partitionSpec in sinkBuilder.overwrite(partitionSpec) will delete all groups under the specified partial partition in the snapshot branch. However, the source side's skipPreloadTargetSnapshot only generates output from target chain partitions present in the delta. If a snapshot group already exists but has no corresponding delta in the target chain partition, it will be overwritten and deleted without being rewritten. The author is advised to add a scenario: partitioned by (region, dt, hr), chain keys (dt, hr), with a snapshot containing region=FR, dt=..., hr=..., and a delta only including region=CN, dt=..., hr=.... After executing compact_chain_table('dt=..., hr=...', true), the FR data should not be lost.

Hi @JingsongLi

Thank you for pointing this out.
I updated CompactChainTableAction to always enable dynamic-partition-overwrite internally when compacting, so only full partitions present in the compacted DataFrame are overwritten and other groups are preserved regardless of the table-level setting.

I also verified that the same issue exists in the Spark compact_chain_table implementation. I have submitted a separate PR(#8529) to fix it there as well.

@JingsongLi

Copy link
Copy Markdown
Contributor

+1

@JingsongLi JingsongLi merged commit aef8121 into apache:master Jul 10, 2026
11 of 13 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