@@ -41,9 +41,9 @@ use crate::client::{
4141 HttpClient , deserialize_catalog_response, deserialize_unexpected_catalog_error,
4242} ;
4343use crate :: types:: {
44- CatalogConfig , CommitTableRequest , CommitTableResponse , CreateTableRequest ,
45- ListNamespaceResponse , ListTableResponse , LoadTableResponse , NamespaceSerde ,
46- RegisterTableRequest , RenameTableRequest ,
44+ CatalogConfig , CommitTableRequest , CommitTableResponse , CreateNamespaceRequest ,
45+ CreateTableRequest , ListNamespaceResponse , ListTablesResponse , LoadTableResult ,
46+ NamespaceResponse , RegisterTableRequest , RenameTableRequest ,
4747} ;
4848
4949/// REST catalog URI
@@ -466,13 +466,7 @@ impl Catalog for RestCatalog {
466466 deserialize_catalog_response :: < ListNamespaceResponse > ( http_response)
467467 . await ?;
468468
469- let ns_identifiers = response
470- . namespaces
471- . into_iter ( )
472- . map ( NamespaceIdent :: from_vec)
473- . collect :: < Result < Vec < NamespaceIdent > > > ( ) ?;
474-
475- namespaces. extend ( ns_identifiers) ;
469+ namespaces. extend ( response. namespaces ) ;
476470
477471 match response. next_page_token {
478472 Some ( token) => next_token = Some ( token) ,
@@ -502,9 +496,9 @@ impl Catalog for RestCatalog {
502496 let request = context
503497 . client
504498 . request ( Method :: POST , context. config . namespaces_endpoint ( ) )
505- . json ( & NamespaceSerde {
506- namespace : namespace. as_ref ( ) . clone ( ) ,
507- properties : Some ( properties ) ,
499+ . json ( & CreateNamespaceRequest {
500+ namespace : namespace. clone ( ) ,
501+ properties,
508502 } )
509503 . build ( ) ?;
510504
@@ -513,8 +507,8 @@ impl Catalog for RestCatalog {
513507 match http_response. status ( ) {
514508 StatusCode :: OK => {
515509 let response =
516- deserialize_catalog_response :: < NamespaceSerde > ( http_response) . await ?;
517- Namespace :: try_from ( response)
510+ deserialize_catalog_response :: < NamespaceResponse > ( http_response) . await ?;
511+ Ok ( Namespace :: from ( response) )
518512 }
519513 StatusCode :: CONFLICT => Err ( Error :: new (
520514 ErrorKind :: Unexpected ,
@@ -537,8 +531,8 @@ impl Catalog for RestCatalog {
537531 match http_response. status ( ) {
538532 StatusCode :: OK => {
539533 let response =
540- deserialize_catalog_response :: < NamespaceSerde > ( http_response) . await ?;
541- Namespace :: try_from ( response)
534+ deserialize_catalog_response :: < NamespaceResponse > ( http_response) . await ?;
535+ Ok ( Namespace :: from ( response) )
542536 }
543537 StatusCode :: NOT_FOUND => Err ( Error :: new (
544538 ErrorKind :: Unexpected ,
@@ -614,7 +608,7 @@ impl Catalog for RestCatalog {
614608 match http_response. status ( ) {
615609 StatusCode :: OK => {
616610 let response =
617- deserialize_catalog_response :: < ListTableResponse > ( http_response) . await ?;
611+ deserialize_catalog_response :: < ListTablesResponse > ( http_response) . await ?;
618612
619613 identifiers. extend ( response. identifiers ) ;
620614
@@ -661,19 +655,15 @@ impl Catalog for RestCatalog {
661655 partition_spec : creation. partition_spec ,
662656 write_order : creation. sort_order ,
663657 stage_create : Some ( false ) ,
664- properties : if creation. properties . is_empty ( ) {
665- None
666- } else {
667- Some ( creation. properties )
668- } ,
658+ properties : creation. properties ,
669659 } )
670660 . build ( ) ?;
671661
672662 let http_response = context. client . query_catalog ( request) . await ?;
673663
674664 let response = match http_response. status ( ) {
675665 StatusCode :: OK => {
676- deserialize_catalog_response :: < LoadTableResponse > ( http_response) . await ?
666+ deserialize_catalog_response :: < LoadTableResult > ( http_response) . await ?
677667 }
678668 StatusCode :: NOT_FOUND => {
679669 return Err ( Error :: new (
@@ -697,7 +687,6 @@ impl Catalog for RestCatalog {
697687
698688 let config = response
699689 . config
700- . unwrap_or_default ( )
701690 . into_iter ( )
702691 . chain ( self . user_config . props . clone ( ) )
703692 . collect ( ) ;
@@ -735,7 +724,7 @@ impl Catalog for RestCatalog {
735724
736725 let response = match http_response. status ( ) {
737726 StatusCode :: OK | StatusCode :: NOT_MODIFIED => {
738- deserialize_catalog_response :: < LoadTableResponse > ( http_response) . await ?
727+ deserialize_catalog_response :: < LoadTableResult > ( http_response) . await ?
739728 }
740729 StatusCode :: NOT_FOUND => {
741730 return Err ( Error :: new (
@@ -748,7 +737,6 @@ impl Catalog for RestCatalog {
748737
749738 let config = response
750739 . config
751- . unwrap_or_default ( )
752740 . into_iter ( )
753741 . chain ( self . user_config . props . clone ( ) )
754742 . collect ( ) ;
@@ -861,9 +849,9 @@ impl Catalog for RestCatalog {
861849
862850 let http_response = context. client . query_catalog ( request) . await ?;
863851
864- let response: LoadTableResponse = match http_response. status ( ) {
852+ let response: LoadTableResult = match http_response. status ( ) {
865853 StatusCode :: OK => {
866- deserialize_catalog_response :: < LoadTableResponse > ( http_response) . await ?
854+ deserialize_catalog_response :: < LoadTableResult > ( http_response) . await ?
867855 }
868856 StatusCode :: NOT_FOUND => {
869857 return Err ( Error :: new (
@@ -905,7 +893,7 @@ impl Catalog for RestCatalog {
905893 context. config . table_endpoint ( commit. identifier ( ) ) ,
906894 )
907895 . json ( & CommitTableRequest {
908- identifier : commit. identifier ( ) . clone ( ) ,
896+ identifier : Some ( commit. identifier ( ) . clone ( ) ) ,
909897 requirements : commit. take_requirements ( ) ,
910898 updates : commit. take_updates ( ) ,
911899 } )
@@ -2428,7 +2416,7 @@ mod tests {
24282416 ) )
24292417 . unwrap ( ) ;
24302418 let reader = BufReader :: new ( file) ;
2431- let resp = serde_json:: from_reader :: < _ , LoadTableResponse > ( reader) . unwrap ( ) ;
2419+ let resp = serde_json:: from_reader :: < _ , LoadTableResult > ( reader) . unwrap ( ) ;
24322420
24332421 Table :: builder ( )
24342422 . metadata ( resp. metadata )
@@ -2568,7 +2556,7 @@ mod tests {
25682556 ) )
25692557 . unwrap ( ) ;
25702558 let reader = BufReader :: new ( file) ;
2571- let resp = serde_json:: from_reader :: < _ , LoadTableResponse > ( reader) . unwrap ( ) ;
2559+ let resp = serde_json:: from_reader :: < _ , LoadTableResult > ( reader) . unwrap ( ) ;
25722560
25732561 Table :: builder ( )
25742562 . metadata ( resp. metadata )
0 commit comments