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

Function test_pk_write_and_commit

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

Source from the content-addressed store, hash-verified

1398
1399 #[tokio::test]
1400 async fn test_pk_write_and_commit() {
1401 let file_io = test_file_io();
1402 let table_path = "memory:/test_pk_write";
1403 setup_dirs(&file_io, table_path).await;
1404
1405 let table = test_pk_table(&file_io, table_path);
1406 let mut table_write = TableWrite::new(&table, "test-user".to_string()).unwrap();
1407
1408 let batch = make_batch(vec![3, 1, 2], vec![30, 10, 20]);
1409 table_write.write_arrow_batch(&batch).await.unwrap();
1410
1411 let messages = table_write.prepare_commit().await.unwrap();
1412 assert_eq!(messages.len(), 1);
1413 assert_eq!(messages[0].new_files.len(), 1);
1414
1415 let file = &messages[0].new_files[0];
1416 assert_eq!(file.row_count, 3);
1417 assert_eq!(file.level, 0);
1418 assert_eq!(file.min_sequence_number, 0);
1419 assert_eq!(file.max_sequence_number, 2);
1420 // min_key and max_key should be non-empty (serialized BinaryRow)
1421 assert!(!file.min_key.is_empty());
1422 assert!(!file.max_key.is_empty());
1423
1424 // Commit
1425 let commit = TableCommit::new(table.clone(), "test-user".to_string());
1426 commit.commit(messages).await.unwrap();
1427
1428 let snap_manager = SnapshotManager::new(file_io.clone(), table_path.to_string());
1429 let snapshot = snap_manager.get_latest_snapshot().await.unwrap().unwrap();
1430 assert_eq!(snapshot.id(), 1);
1431 assert_eq!(snapshot.total_record_count(), Some(3));
1432 }
1433
1434 #[tokio::test]
1435 async fn test_pk_write_sorted_output() {

Callers

nothing calls this directly

Calls 8

test_pk_tableFunction · 0.85
write_arrow_batchMethod · 0.80
get_latest_snapshotMethod · 0.80
test_file_ioFunction · 0.70
setup_dirsFunction · 0.70
make_batchFunction · 0.70
prepare_commitMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected