@@ -199,7 +199,7 @@ impl Catalog for RestCatalog {
199199 }
200200 /// Check if a table exists
201201 async fn tabular_exists ( & self , identifier : & Identifier ) -> Result < bool , Error > {
202- catalog_api_api:: view_exists (
202+ match catalog_api_api:: view_exists (
203203 & self . configuration ,
204204 self . name . as_deref ( ) ,
205205 & identifier. namespace ( ) . to_string ( ) ,
@@ -215,8 +215,11 @@ impl Catalog for RestCatalog {
215215 . await
216216 } )
217217 . await
218- . map ( |_| true )
219- . map_err ( Into :: < Error > :: into)
218+ . map_err ( Into :: < Error > :: into) {
219+ Ok ( _) => Ok ( true ) ,
220+ Err ( Error :: NotFound ( _) ) => Ok ( false ) ,
221+ Err ( e) => Err ( e) ,
222+ }
220223 }
221224 /// Drop a table and delete all data and metadata files.
222225 async fn drop_table ( & self , identifier : & Identifier ) -> Result < ( ) , Error > {
@@ -747,6 +750,21 @@ pub mod tests {
747750 . expect ( "Failed to list Tables" ) ;
748751 assert_eq ! ( tables[ 0 ] . to_string( ) , "tpch.lineitem" . to_owned( ) ) ;
749752
753+ assert_eq ! (
754+ iceberg_catalog
755+ . tabular_exists( & Identifier :: new( & [ "tpch" . to_owned( ) ] , "lineitem" ) )
756+ . await
757+ . map_err( |s| s. to_string( ) ) ,
758+ Ok ( true )
759+ ) ;
760+ assert_eq ! (
761+ iceberg_catalog
762+ . tabular_exists( & Identifier :: new( & [ "tpch" . to_owned( ) ] , "non_existing_table" ) )
763+ . await
764+ . map_err( |s| s. to_string( ) ) ,
765+ Ok ( false )
766+ ) ;
767+
750768 let sql = "insert into warehouse.tpch.lineitem select * from lineitem;" ;
751769
752770 let plan = ctx. state ( ) . create_logical_plan ( sql) . await . unwrap ( ) ;
0 commit comments