@@ -7,6 +7,7 @@ compile_error!(
77 for this crate to function properly."
88) ;
99
10+ use datafusion_common:: DataFusionError ;
1011use deltalake_core:: logstore:: { default_logstore, logstores, LogStore , LogStoreFactory } ;
1112use reqwest:: header:: { HeaderValue , InvalidHeaderValue , AUTHORIZATION } ;
1213use reqwest:: Url ;
@@ -23,7 +24,9 @@ use crate::models::{
2324} ;
2425
2526use deltalake_core:: data_catalog:: DataCatalogResult ;
26- use deltalake_core:: { DataCatalog , DataCatalogError , DeltaResult , DeltaTableBuilder , DeltaTableError , Path } ;
27+ use deltalake_core:: {
28+ DataCatalog , DataCatalogError , DeltaResult , DeltaTableBuilder , DeltaTableError , Path ,
29+ } ;
2730
2831use crate :: client:: retry:: * ;
2932use deltalake_core:: storage:: {
@@ -74,7 +77,7 @@ pub enum UnityCatalogError {
7477 #[ error( "Invalid Unity Catalog Table URI: {table_uri}" ) ]
7578 InvalidTableURI {
7679 /// Table URI
77- table_uri : String
80+ table_uri : String ,
7881 } ,
7982
8083 /// Unknown configuration key
@@ -492,7 +495,7 @@ impl UnityCatalogBuilder {
492495 let uri_parts: Vec < & str > = table_uri[ 5 ..] . split ( '.' ) . collect ( ) ;
493496 if uri_parts. len ( ) != 3 {
494497 return Err ( UnityCatalogError :: InvalidTableURI {
495- table_uri : table_uri. to_string ( )
498+ table_uri : table_uri. to_string ( ) ,
496499 } ) ;
497500 }
498501
@@ -501,17 +504,17 @@ impl UnityCatalogBuilder {
501504 let table_name = uri_parts[ 2 ] ;
502505
503506 let unity_catalog = UnityCatalogBuilder :: from_env ( ) . build ( ) ?;
504- let storage_location = unity_catalog. get_table_storage_location (
505- Some ( catalog_id. to_string ( ) ) ,
506- database_name,
507- table_name
508- ) . await ?;
507+ let storage_location = unity_catalog
508+ . get_table_storage_location ( Some ( catalog_id. to_string ( ) ) , database_name, table_name)
509+ . await ?;
509510 let temp_creds_res = unity_catalog
510511 . get_temp_table_credentials ( catalog_id, database_name, table_name)
511512 . await ?;
512513 let credentials = match temp_creds_res {
513514 TableTempCredentialsResponse :: Success ( temp_creds) => {
514- temp_creds. get_credentials ( ) . unwrap ( )
515+ temp_creds. get_credentials ( ) . ok_or_else ( || {
516+ DataFusionError :: External ( UnityCatalogError :: MissingCredential . into ( ) )
517+ } ) ?
515518 }
516519 TableTempCredentialsResponse :: Error ( _error) => {
517520 return Err ( UnityCatalogError :: TemporaryCredentialsFetchFailure )
@@ -799,8 +802,7 @@ impl ObjectStoreFactory for UnityCatalogFactory {
799802 ) -> DeltaResult < ( ObjectStoreRef , Path ) > {
800803 use futures:: executor:: block_on;
801804
802- let ( table_path, temp_creds) = block_on (
803- UnityCatalogBuilder :: get_uc_location_and_token (
805+ let ( table_path, temp_creds) = block_on ( UnityCatalogBuilder :: get_uc_location_and_token (
804806 table_uri. as_str ( ) ,
805807 ) ) ?;
806808
0 commit comments