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

Function test_blob_write_and_commit

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

Source from the content-addressed store, hash-verified

848
849 #[tokio::test]
850 async fn test_blob_write_and_commit() {
851 let file_io = test_file_io();
852 let table_path = "memory:/test_blob_write";
853 setup_dirs(&file_io, table_path).await;
854
855 let table = Table::new(
856 file_io.clone(),
857 Identifier::new("default", "test_blob_table"),
858 table_path.to_string(),
859 test_blob_table_schema(),
860 None,
861 );
862
863 let mut table_write = TableWrite::new(&table, "test-user".to_string()).unwrap();
864
865 let schema = Arc::new(ArrowSchema::new(vec![
866 ArrowField::new("id", ArrowDataType::Int32, false),
867 ArrowField::new("payload", ArrowDataType::Binary, true),
868 ]));
869 let batch = RecordBatch::try_new(
870 schema,
871 vec![
872 Arc::new(Int32Array::from(vec![1, 2, 3])),
873 Arc::new(arrow_array::BinaryArray::from(vec![
874 Some(b"hello" as &[u8]),
875 None,
876 Some(b"world"),
877 ])),
878 ],
879 )
880 .unwrap();
881
882 table_write.write_arrow_batch(&batch).await.unwrap();
883 let messages = table_write.prepare_commit().await.unwrap();
884
885 assert_eq!(messages.len(), 1);
886 // Should have 2 files: 1 parquet (normal cols) + 1 blob (payload)
887 assert_eq!(messages[0].new_files.len(), 2);
888
889 let parquet_files: Vec<_> = messages[0]
890 .new_files
891 .iter()
892 .filter(|f| f.file_name.ends_with(".parquet"))
893 .collect();
894 let blob_files: Vec<_> = messages[0]
895 .new_files
896 .iter()
897 .filter(|f| f.file_name.ends_with(".blob"))
898 .collect();
899 assert_eq!(parquet_files.len(), 1);
900 assert_eq!(blob_files.len(), 1);
901
902 assert_eq!(parquet_files[0].row_count, 3);
903 assert_eq!(blob_files[0].row_count, 3);
904 assert_eq!(blob_files[0].write_cols, Some(vec!["payload".to_string()]));
905
906 // Commit and verify snapshot
907 let commit = TableCommit::new(table, "test-user".to_string());

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected