@@ -72,6 +72,16 @@ impl<'a> FastAppendAction<'a> {
7272 Ok ( self )
7373 }
7474
75+ /// Set snapshot summary properties.
76+ pub fn set_snapshot_properties (
77+ & mut self ,
78+ snapshot_properties : HashMap < String , String > ,
79+ ) -> Result < & mut Self > {
80+ self . snapshot_produce_action
81+ . set_snapshot_properties ( snapshot_properties) ?;
82+ Ok ( self )
83+ }
84+
7585 /// Adds existing parquet files
7686 ///
7787 /// Note: This API is not yet fully supported in version 0.5.x.
@@ -211,6 +221,8 @@ impl SnapshotProduceOperation for FastAppendOperation {
211221
212222#[ cfg( test) ]
213223mod tests {
224+ use std:: collections:: HashMap ;
225+
214226 use crate :: scan:: tests:: TableTestFixture ;
215227 use crate :: spec:: {
216228 DataContentType , DataFileBuilder , DataFileFormat , Literal , MAIN_BRANCH , Struct ,
@@ -228,6 +240,44 @@ mod tests {
228240 assert ! ( action. apply( ) . await . is_err( ) ) ;
229241 }
230242
243+ #[ tokio:: test]
244+ async fn test_set_snapshot_properties ( ) {
245+ let table = make_v2_minimal_table ( ) ;
246+ let tx = Transaction :: new ( & table) ;
247+ let mut action = tx. fast_append ( None , vec ! [ ] ) . unwrap ( ) ;
248+
249+ let mut snapshot_properties = HashMap :: new ( ) ;
250+ snapshot_properties. insert ( "key" . to_string ( ) , "val" . to_string ( ) ) ;
251+ action. set_snapshot_properties ( snapshot_properties) . unwrap ( ) ;
252+ let data_file = DataFileBuilder :: default ( )
253+ . content ( DataContentType :: Data )
254+ . file_path ( "test/1.parquet" . to_string ( ) )
255+ . file_format ( DataFileFormat :: Parquet )
256+ . file_size_in_bytes ( 100 )
257+ . record_count ( 1 )
258+ . partition_spec_id ( table. metadata ( ) . default_partition_spec_id ( ) )
259+ . partition ( Struct :: from_iter ( [ Some ( Literal :: long ( 300 ) ) ] ) )
260+ . build ( )
261+ . unwrap ( ) ;
262+ action. add_data_files ( vec ! [ data_file] ) . unwrap ( ) ;
263+ let tx = action. apply ( ) . await . unwrap ( ) ;
264+
265+ // Check customized properties is contained in snapshot summary properties.
266+ let new_snapshot = if let TableUpdate :: AddSnapshot { snapshot } = & tx. updates [ 0 ] {
267+ snapshot
268+ } else {
269+ unreachable ! ( )
270+ } ;
271+ assert_eq ! (
272+ new_snapshot
273+ . summary( )
274+ . additional_properties
275+ . get( "key" )
276+ . unwrap( ) ,
277+ "val"
278+ ) ;
279+ }
280+
231281 #[ tokio:: test]
232282 async fn test_fast_append_action ( ) {
233283 let table = make_v2_minimal_table ( ) ;
0 commit comments