This is an automated email from the ASF dual-hosted git repository.

JingsongLi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-rust.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a710616 [core] Honor snapshot.ignore-empty-commit for empty appends 
(#1528)
2a710616 is described below

commit 2a7106169b4007e2428b0bd14847381fec599fee
Author: Jingsong Lee <[email protected]>
AuthorDate: Tue Nov 24 16:18:00 2026 +0800

    [core] Honor snapshot.ignore-empty-commit for empty appends (#1528)
---
 crates/paimon/src/spec/core_options.rs  |  7 ++++++
 crates/paimon/src/table/table_commit.rs | 39 ++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/crates/paimon/src/spec/core_options.rs 
b/crates/paimon/src/spec/core_options.rs
index 1553eac9..921ef8bd 100644
--- a/crates/paimon/src/spec/core_options.rs
+++ b/crates/paimon/src/spec/core_options.rs
@@ -73,6 +73,7 @@ const COMMIT_MAX_RETRIES_OPTION: &str = "commit.max-retries";
 const COMMIT_TIMEOUT_OPTION: &str = "commit.timeout";
 const COMMIT_MIN_RETRY_WAIT_OPTION: &str = "commit.min-retry-wait";
 const COMMIT_MAX_RETRY_WAIT_OPTION: &str = "commit.max-retry-wait";
+const SNAPSHOT_IGNORE_EMPTY_COMMIT_OPTION: &str = 
"snapshot.ignore-empty-commit";
 const FILE_COMPRESSION_OPTION: &str = "file.compression";
 const FILE_COMPRESSION_ZSTD_LEVEL_OPTION: &str = "file.compression.zstd-level";
 const FILE_FORMAT_OPTION: &str = "file.format";
@@ -1546,6 +1547,12 @@ impl<'a> CoreOptions<'a> {
         (!keys.is_empty()).then_some(keys)
     }
 
+    pub(crate) fn snapshot_ignore_empty_commit(&self) -> bool {
+        self.options
+            .get(SNAPSHOT_IGNORE_EMPTY_COMMIT_OPTION)
+            .is_none_or(|value| !value.eq_ignore_ascii_case("false"))
+    }
+
     pub fn commit_max_retries(&self) -> u32 {
         self.options
             .get(COMMIT_MAX_RETRIES_OPTION)
diff --git a/crates/paimon/src/table/table_commit.rs 
b/crates/paimon/src/table/table_commit.rs
index 7171b977..d6c20c58 100644
--- a/crates/paimon/src/table/table_commit.rs
+++ b/crates/paimon/src/table/table_commit.rs
@@ -232,6 +232,7 @@ impl TableCommit {
             ))
         };
         let core_options = CoreOptions::new(table.schema().options());
+        let ignore_empty_commit = core_options.snapshot_ignore_empty_commit();
         let total_buckets = core_options.bucket();
         let commit_max_retries = core_options.commit_max_retries();
         let commit_timeout_ms = core_options.commit_timeout_ms();
@@ -249,7 +250,7 @@ impl TableCommit {
             snapshot_manager,
             snapshot_commit,
             commit_user,
-            ignore_empty_commit: true,
+            ignore_empty_commit,
             total_buckets,
             commit_max_retries,
             commit_timeout_ms,
@@ -5322,6 +5323,42 @@ mod tests {
         assert!(snapshot.is_none());
     }
 
+    #[tokio::test]
+    async fn test_empty_append_honors_snapshot_option() {
+        let file_io = test_file_io();
+        let table_path = "memory:/test_empty_append_snapshot_option";
+        setup_dirs(&file_io, table_path).await;
+        let table = test_table_with_options(
+            &file_io,
+            table_path,
+            HashMap::from([
+                ("partition".into(), "name".into()),
+                ("snapshot.ignore-empty-commit".into(), "false".into()),
+            ]),
+        );
+        let commit = table.new_write_builder().new_commit();
+        let snapshots = table.snapshot_manager();
+
+        commit
+            .clone()
+            .with_ignore_empty_commit(true)
+            .commit(vec![])
+            .await
+            .unwrap();
+        commit.overwrite(vec![], None).await.unwrap();
+        assert!(snapshots.get_latest_snapshot().await.unwrap().is_none());
+
+        commit.commit(vec![]).await.unwrap();
+        let snapshot = snapshots
+            .get_latest_snapshot()
+            .await
+            .unwrap()
+            .expect("the table option allows empty append snapshots");
+        assert_eq!(snapshot.id(), 1);
+        assert_eq!(*snapshot.commit_kind(), CommitKind::APPEND);
+        assert_eq!(snapshot.total_record_count(), Some(0));
+    }
+
     #[tokio::test]
     async fn test_index_only_commit_creates_snapshot() {
         let file_io = test_file_io();

Reply via email to