@@ -916,23 +916,34 @@ async fn rename_clustering_column_fails() -> Result<(), Box<dyn std::error::Erro
916916// OPERATION STRING tests
917917// ============================================================================
918918
919- // Reads `commitInfo.operation` from a commit JSON written to the local filesystem.
920- fn read_commit_operation ( table_path : & str , version : u64 ) -> String {
919+ // Reads the `commitInfo` object from a commit JSON written to the local filesystem.
920+ fn read_commit_info ( table_path : & str , version : u64 ) -> serde_json :: Value {
921921 let log_file = format ! ( "{table_path}/_delta_log/{version:020}.json" ) ;
922922 let contents = std:: fs:: read_to_string ( & log_file) . expect ( "read log file" ) ;
923923 for line in contents. lines ( ) {
924924 let action: serde_json:: Value = serde_json:: from_str ( line) . expect ( "parse action" ) ;
925925 if let Some ( ci) = action. get ( "commitInfo" ) {
926- return ci
927- . get ( "operation" )
928- . and_then ( |v| v. as_str ( ) )
929- . expect ( "operation field" )
930- . to_string ( ) ;
926+ return ci. clone ( ) ;
931927 }
932928 }
933929 panic ! ( "no commitInfo in commit {version}" ) ;
934930}
935931
932+ fn read_commit_operation ( table_path : & str , version : u64 ) -> String {
933+ read_commit_info ( table_path, version)
934+ . get ( "operation" )
935+ . and_then ( |v| v. as_str ( ) )
936+ . expect ( "operation field" )
937+ . to_string ( )
938+ }
939+
940+ fn read_commit_is_blind_append ( table_path : & str , version : u64 ) -> bool {
941+ read_commit_info ( table_path, version)
942+ . get ( "isBlindAppend" )
943+ . and_then ( |v| v. as_bool ( ) )
944+ . expect ( "isBlindAppend field" )
945+ }
946+
936947#[ tokio:: test]
937948async fn alter_commit_operation_add_columns ( ) -> DeltaResult < ( ) > {
938949 let ( _temp_dir, table_path, engine) = test_table_setup ( ) ?;
@@ -981,3 +992,34 @@ async fn alter_commit_operation_mixed_ops_joined_with_plus() -> DeltaResult<()>
981992 ) ;
982993 Ok ( ( ) )
983994}
995+
996+ #[ tokio:: test]
997+ async fn alter_commit_is_blind_append_true_for_add_columns ( ) -> DeltaResult < ( ) > {
998+ let ( _temp_dir, table_path, engine) = test_table_setup ( ) ?;
999+ let snapshot =
1000+ create_table_and_load_snapshot ( & table_path, simple_schema ( ) , engine. as_ref ( ) , & [ ] ) ?;
1001+ snapshot
1002+ . alter_table ( )
1003+ . add_column ( StructField :: nullable ( "email" , DataType :: STRING ) )
1004+ . build ( engine. as_ref ( ) , committer ( ) ) ?
1005+ . commit ( engine. as_ref ( ) ) ?
1006+ . unwrap_committed ( ) ;
1007+ assert ! ( read_commit_is_blind_append( & table_path, 1 ) ) ;
1008+ Ok ( ( ) )
1009+ }
1010+
1011+ #[ tokio:: test]
1012+ async fn alter_commit_is_blind_append_true_for_mixed_blind_ops ( ) -> DeltaResult < ( ) > {
1013+ let ( _temp_dir, table_path, engine) = test_table_setup ( ) ?;
1014+ let snapshot =
1015+ create_table_and_load_snapshot ( & table_path, simple_schema ( ) , engine. as_ref ( ) , & [ ] ) ?;
1016+ snapshot
1017+ . alter_table ( )
1018+ . add_column ( StructField :: nullable ( "email" , DataType :: STRING ) )
1019+ . set_nullable ( column_name ! ( "id" ) )
1020+ . build ( engine. as_ref ( ) , committer ( ) ) ?
1021+ . commit ( engine. as_ref ( ) ) ?
1022+ . unwrap_committed ( ) ;
1023+ assert ! ( read_commit_is_blind_append( & table_path, 1 ) ) ;
1024+ Ok ( ( ) )
1025+ }
0 commit comments