Skip to content
Open
24 changes: 24 additions & 0 deletions docs/docs/multimodal-table/data-evolution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,30 @@ joins that can broadcast a small input. Compare complete SQL execution time and
executor disk usage with representative data before enabling it. The shared
result is released after the command, including when execution fails.

For a Paimon append source with large columns used only by INSERT, Spark can
keep those columns out of the shared result:

```sql
ALTER TABLE target_table SET TBLPROPERTIES (
'data-evolution.merge-into.join-reuse' = 'true',
'data-evolution.merge-into.join-reuse.narrow-source.enabled' = 'true'
);
```

The narrow-source option is disabled by default. It requires a single INT or
BIGINT equality key and a direct source table or a projection of its columns.
Spark pins the source snapshot before reading it and retrieves INSERT columns
with another source scan. Source duplicates and NULL keys retain the original
MERGE semantics. Unsupported statements, sources without a snapshot, and
statements using `data-evolution.merge-into.source-persist` keep the original
execution path. Schema-only changes newer than the data snapshot and retained
tags without a numbered snapshot file also use the original path.
Composite fallback/primary-branch sources also keep the original execution path.
This can reduce shuffle and disk cache size for wide sources,
but the extra scan and membership join can increase elapsed time. Compare
complete SQL execution time for the expected UPDATE/INSERT mix before enabling
it. This option does not perform positional source reads.

### Flink SQL

Use the `data_evolution_merge_into` procedure for matched updates. It runs in
Expand Down
18 changes: 12 additions & 6 deletions docs/generated/core_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,6 @@
<td>MemorySize</td>
<td>When incremental size is bigger than this threshold, force a full compaction.</td>
</tr>
<tr>
<td><h5>continuous-compaction.initial-scan-mode</h5></td>
<td style="word-wrap: break-word;">earliest</td>
<td><p>Enum</p></td>
<td>Initial snapshot mode for dedicated streaming compaction. When set to 'earliest' (the default), compaction starts from the earliest available snapshot if no COMPACT snapshot exists; when a COMPACT snapshot exists, compaction always resumes from the snapshot after it. When set to 'latest', the latest snapshot is read in ALL mode as the initial baseline and subsequent scans start from the next snapshot. The 'latest' mode skips historical snapshot changes and should only be used when historical changelog replay is not required.<br /><br />Possible values:<ul><li>"earliest": Read snapshots from the earliest available snapshot.</li><li>"latest": Read the latest snapshot as the initial full baseline.</li></ul></td>
</tr>
<tr>
<td><h5>compaction.max-size-amplification-percent</h5></td>
<td style="word-wrap: break-word;">200</td>
Expand Down Expand Up @@ -506,6 +500,12 @@
<td><p>Enum</p></td>
<td>Specify the consumer consistency mode for table.<br /><br />Possible values:<ul><li>"exactly-once": Readers consume data at snapshot granularity, and strictly ensure that the snapshot-id recorded in the consumer is the snapshot-id + 1 that all readers have exactly consumed.</li><li>"at-least-once": Each reader consumes snapshots at a different rate, and the snapshot with the slowest consumption progress among all readers will be recorded in the consumer.</li></ul></td>
</tr>
<tr>
<td><h5>continuous-compaction.initial-scan-mode</h5></td>
<td style="word-wrap: break-word;">earliest</td>
<td><p>Enum</p></td>
<td>Initial snapshot mode for dedicated streaming compaction. When set to 'earliest' (the default), compaction starts from the earliest available snapshot if no COMPACT snapshot exists; when a COMPACT snapshot exists, compaction always resumes from the snapshot after it. When set to 'latest', the latest snapshot is read in ALL mode as the initial baseline and subsequent scans start from the next snapshot. The 'latest' mode skips historical snapshot changes and should only be used when historical changelog replay is not required.<br /><br />Possible values:<ul><li>"earliest": Read snapshots from the earliest available snapshot.</li><li>"latest": Read the latest snapshot as the initial full baseline.</li></ul></td>
</tr>
<tr>
<td><h5>continuous.discovery-interval</h5></td>
<td style="word-wrap: break-word;">10 s</td>
Expand Down Expand Up @@ -578,6 +578,12 @@
<td>Boolean</td>
<td>Whether to reuse a disk-persisted match result between deterministic UPDATE and INSERT actions on data evolution tables without DELETE actions or dedicated BLOB/VECTOR columns. This replaces the two action joins with a full outer join and trades repeated target scans for shuffle and executor-local disk storage. Requires Spark adaptive query execution and adaptive partition coalescing; otherwise the original join path is used.</td>
</tr>
<tr>
<td><h5>data-evolution.merge-into.join-reuse.narrow-source.enabled</h5></td>
<td style="word-wrap: break-word;">false</td>
<td>Boolean</td>
<td>Whether Spark MERGE join reuse excludes INSERT-only source columns from the shared result and reads them again from a pinned source snapshot. Requires join reuse, a simple Paimon append source and an INT or BIGINT equality key. It reduces shared shuffle and cache size at the cost of another source scan. Unsupported sources use the original shared result.</td>
</tr>
<tr>
<td><h5>data-evolution.merge-into.source-persist</h5></td>
<td style="word-wrap: break-word;">false</td>
Expand Down
15 changes: 15 additions & 0 deletions paimon-api/src/main/java/org/apache/paimon/CoreOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,17 @@ public String toString() {
+ "Requires Spark adaptive query execution and adaptive partition "
+ "coalescing; otherwise the original join path is used.");

public static final ConfigOption<Boolean> DATA_EVOLUTION_MERGE_INTO_NARROW_SOURCE =
key("data-evolution.merge-into.join-reuse.narrow-source.enabled")
.booleanType()
.defaultValue(false)
.withDescription(
"Whether Spark MERGE join reuse excludes INSERT-only source columns from "
+ "the shared result and reads them again from a pinned source snapshot. "
+ "Requires join reuse, a simple Paimon append source and an INT or BIGINT "
+ "equality key. It reduces shared shuffle and cache size at the cost of "
+ "another source scan. Unsupported sources use the original shared result.");

public static final ConfigOption<Boolean> DATA_EVOLUTION_COMPACTION_SPLIT_LARGE_FILES =
key("data-evolution.compaction.split-large-files")
.booleanType()
Expand Down Expand Up @@ -4862,6 +4873,10 @@ public boolean dataEvolutionMergeIntoJoinReuse() {
return options.get(DATA_EVOLUTION_MERGE_INTO_JOIN_REUSE);
}

public boolean dataEvolutionMergeIntoNarrowSource() {
return options.get(DATA_EVOLUTION_MERGE_INTO_NARROW_SOURCE);
}

public boolean blobCompactionEnabled() {
return options.get(BLOB_COMPACTION_ENABLED);
}
Expand Down
Loading
Loading