@@ -3024,8 +3024,18 @@ impl From<ConfigFileDecryptionProperties> for FileDecryptionProperties {
30243024}
30253025
30263026#[ cfg( feature = "parquet_encryption" ) ]
3027- impl From < & Arc < FileDecryptionProperties > > for ConfigFileDecryptionProperties {
3028- fn from ( f : & Arc < FileDecryptionProperties > ) -> Self {
3027+ impl TryFrom < & Arc < FileDecryptionProperties > > for ConfigFileDecryptionProperties {
3028+ type Error = DataFusionError ;
3029+
3030+ fn try_from ( f : & Arc < FileDecryptionProperties > ) -> Result < Self > {
3031+ let footer_key = f. footer_key ( None ) . map_err ( |e| {
3032+ DataFusionError :: Configuration ( format ! (
3033+ "Could not retrieve footer key from FileDecryptionProperties. \
3034+ Note that conversion to ConfigFileDecryptionProperties is not supported \
3035+ when using a key retriever: {e}"
3036+ ) )
3037+ } ) ?;
3038+
30293039 let ( column_names_vec, column_keys_vec) = f. column_keys ( ) ;
30303040 let mut column_decryption_properties: HashMap <
30313041 String ,
@@ -3039,14 +3049,12 @@ impl From<&Arc<FileDecryptionProperties>> for ConfigFileDecryptionProperties {
30393049 }
30403050
30413051 let aad_prefix = f. aad_prefix ( ) . cloned ( ) . unwrap_or_default ( ) ;
3042- ConfigFileDecryptionProperties {
3043- footer_key_as_hex : hex:: encode (
3044- f. footer_key ( None ) . unwrap_or_default ( ) . as_ref ( ) ,
3045- ) ,
3052+ Ok ( ConfigFileDecryptionProperties {
3053+ footer_key_as_hex : hex:: encode ( footer_key. as_ref ( ) ) ,
30463054 column_decryption_properties,
30473055 aad_prefix_as_hex : hex:: encode ( aad_prefix) ,
30483056 footer_signature_verification : f. check_plaintext_footer_integrity ( ) ,
3049- }
3057+ } )
30503058 }
30513059}
30523060
@@ -3519,7 +3527,8 @@ mod tests {
35193527 Arc :: new ( FileEncryptionProperties :: from ( config_encrypt. clone ( ) ) ) ;
35203528 assert_eq ! ( file_encryption_properties, encryption_properties_built) ;
35213529
3522- let config_decrypt = ConfigFileDecryptionProperties :: from ( & decryption_properties) ;
3530+ let config_decrypt =
3531+ ConfigFileDecryptionProperties :: try_from ( & decryption_properties) . unwrap ( ) ;
35233532 let decryption_properties_built =
35243533 Arc :: new ( FileDecryptionProperties :: from ( config_decrypt. clone ( ) ) ) ;
35253534 assert_eq ! ( decryption_properties, decryption_properties_built) ;
0 commit comments