@@ -552,6 +552,50 @@ async fn prepared_build_validates_descriptor_and_builder_changes() -> Result<()>
552552 Ok ( ( ) )
553553}
554554
555+ #[ tokio:: test]
556+ async fn prepared_build_revalidates_public_keys_at_execution ( ) -> Result < ( ) > {
557+ let build = batch ( vec ! [ Some ( 1 ) , Some ( 2 ) ] ) ;
558+ let base = join ( build. schema ( ) , build. clone ( ) ) ?;
559+ let keys: JoinOn = vec ! [ (
560+ Arc :: new( Column :: new( "payload" , 1 ) ) ,
561+ Arc :: new( Column :: new( "payload" , 1 ) ) ,
562+ ) ] ;
563+ let ordinary = base
564+ . builder ( )
565+ . with_on ( keys. clone ( ) )
566+ . with_new_children ( vec ! [
567+ TestMemoryExec :: try_new_exec( & [ vec![ build. clone( ) ] ] , build. schema( ) , None ) ?,
568+ Arc :: clone( base. right( ) ) ,
569+ ] ) ?
570+ . build ( ) ?;
571+ assert_batches_eq ! (
572+ [
573+ "+-----+---------+-----+---------+" ,
574+ "| key | payload | key | payload |" ,
575+ "+-----+---------+-----+---------+" ,
576+ "| 1 | 10 | 1 | 10 |" ,
577+ "| 2 | 11 | 2 | 11 |" ,
578+ "+-----+---------+-----+---------+" ,
579+ ] ,
580+ & run( & ordinary) . await ?
581+ ) ;
582+
583+ let prepared =
584+ prepare ( & base, vec ! [ build] , Arc :: new ( GreedyMemoryPool :: new ( 1 << 20 ) ) ) . await ?;
585+ let mut attached = base. builder ( ) . with_prepared_build ( prepared) . build ( ) ?;
586+ attached. on = keys;
587+ let error = run ( & attached)
588+ . await
589+ . expect_err ( "changed public keys must not probe the old prepared table" ) ;
590+ assert ! ( matches!( error, DataFusionError :: Plan ( _) ) , "{error}" ) ;
591+ assert ! (
592+ error
593+ . to_string( )
594+ . contains( "does not match schema, keys or null equality" )
595+ ) ;
596+ Ok ( ( ) )
597+ }
598+
555599#[ tokio:: test]
556600async fn prepared_build_rejects_view_payload_before_consumption ( ) -> Result < ( ) > {
557601 let build = RecordBatch :: try_from_iter ( [
0 commit comments