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

Function test_drop_partitions

crates/paimon/src/table/table_commit.rs:1375–1417  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1373
1374 #[tokio::test]
1375 async fn test_drop_partitions() {
1376 let file_io = test_file_io();
1377 let table_path = "memory:/test_drop_partitions";
1378 setup_dirs(&file_io, table_path).await;
1379
1380 let commit = setup_partitioned_commit(&file_io, table_path);
1381
1382 // Append data for partitions "a", "b", "c"
1383 commit
1384 .commit(vec![
1385 CommitMessage::new(
1386 partition_bytes("a"),
1387 0,
1388 vec![test_data_file("data-a.parquet", 100)],
1389 ),
1390 CommitMessage::new(
1391 partition_bytes("b"),
1392 0,
1393 vec![test_data_file("data-b.parquet", 200)],
1394 ),
1395 CommitMessage::new(
1396 partition_bytes("c"),
1397 0,
1398 vec![test_data_file("data-c.parquet", 300)],
1399 ),
1400 ])
1401 .await
1402 .unwrap();
1403
1404 // Drop partitions "a" and "c"
1405 let partitions = vec![
1406 HashMap::from([("pt".to_string(), Some(Datum::String("a".to_string())))]),
1407 HashMap::from([("pt".to_string(), Some(Datum::String("c".to_string())))]),
1408 ];
1409 commit.truncate_partitions(partitions).await.unwrap();
1410
1411 let snap_manager = SnapshotManager::new(file_io.clone(), table_path.to_string());
1412 let snapshot = snap_manager.get_latest_snapshot().await.unwrap().unwrap();
1413 assert_eq!(snapshot.id(), 2);
1414 assert_eq!(snapshot.commit_kind(), &CommitKind::OVERWRITE);
1415 // 600 - 100 (a) - 300 (c) = 200
1416 assert_eq!(snapshot.total_record_count(), Some(200));
1417 }
1418
1419 fn null_partition_bytes() -> Vec<u8> {
1420 let mut builder = BinaryRowBuilder::new(1);

Callers

nothing calls this directly

Calls 6

setup_partitioned_commitFunction · 0.85
truncate_partitionsMethod · 0.80
get_latest_snapshotMethod · 0.80
test_file_ioFunction · 0.70
setup_dirsFunction · 0.70
commitMethod · 0.45

Tested by

no test coverage detected