MCPcopy Create free account
hub / github.com/apache/paimon-rust / test_write_partitioned

Function test_write_partitioned

crates/paimon/src/table/table_write.rs:1004–1034  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1002
1003 #[tokio::test]
1004 async fn test_write_partitioned() {
1005 let file_io = test_file_io();
1006 let table_path = "memory:/test_table_write_partitioned";
1007 setup_dirs(&file_io, table_path).await;
1008
1009 let table = test_partitioned_table(&file_io, table_path);
1010 let mut table_write = TableWrite::new(&table, "test-user".to_string()).unwrap();
1011
1012 let batch = make_partitioned_batch(vec!["a", "b", "a"], vec![1, 2, 3]);
1013 table_write.write_arrow_batch(&batch).await.unwrap();
1014
1015 let messages = table_write.prepare_commit().await.unwrap();
1016 // Should have 2 commit messages (one per partition)
1017 assert_eq!(messages.len(), 2);
1018
1019 let total_rows: i64 = messages
1020 .iter()
1021 .flat_map(|m| &m.new_files)
1022 .map(|f| f.row_count)
1023 .sum();
1024 assert_eq!(total_rows, 3);
1025
1026 // Commit and verify
1027 let commit = TableCommit::new(table, "test-user".to_string());
1028 commit.commit(messages).await.unwrap();
1029
1030 let snap_manager = SnapshotManager::new(file_io.clone(), table_path.to_string());
1031 let snapshot = snap_manager.get_latest_snapshot().await.unwrap().unwrap();
1032 assert_eq!(snapshot.id(), 1);
1033 assert_eq!(snapshot.total_record_count(), Some(3));
1034 }
1035
1036 #[tokio::test]
1037 async fn test_write_empty_batch() {

Callers

nothing calls this directly

Calls 9

make_partitioned_batchFunction · 0.85
write_arrow_batchMethod · 0.80
get_latest_snapshotMethod · 0.80
test_file_ioFunction · 0.70
setup_dirsFunction · 0.70
test_partitioned_tableFunction · 0.70
prepare_commitMethod · 0.45
iterMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected