@@ -287,26 +287,31 @@ impl Catalog for SqlCatalog {
287287 "INSERT INTO {NAMESPACE_TABLE_NAME} ({CATALOG_FIELD_CATALOG_NAME}, {NAMESPACE_FIELD_NAME}, {NAMESPACE_FIELD_PROPERTY_KEY}, {NAMESPACE_FIELD_PROPERTY_VALUE})
288288 VALUES (?, ?, ?, ?)" ) ;
289289 if !properties. is_empty ( ) {
290- let mut query_args = Vec :: with_capacity ( properties. len ( ) * 4 ) ;
291- let mut properties_insert = insert. clone ( ) ;
292- for ( index, ( key, value) ) in properties. iter ( ) . enumerate ( ) {
290+ let mut insert_properties = properties. clone ( ) ;
291+ insert_properties. insert ( "exists" . to_string ( ) , "true" . to_string ( ) ) ;
292+
293+ let mut query_args = Vec :: with_capacity ( insert_properties. len ( ) * 4 ) ;
294+ let mut insert_stmt = insert. clone ( ) ;
295+ for ( index, ( key, value) ) in insert_properties. iter ( ) . enumerate ( ) {
293296 query_args. extend_from_slice ( & [
294297 Some ( self . name . as_str ( ) ) ,
295298 Some ( namespace_str. as_str ( ) ) ,
296299 Some ( key. as_str ( ) ) ,
297300 Some ( value. as_str ( ) ) ,
298301 ] ) ;
299302 if index > 0 {
300- properties_insert = format ! ( "{properties_insert} , (?, ?, ?, ?)") ;
303+ insert_stmt . push_str ( " , (?, ?, ?, ?)") ;
301304 }
302305 }
303306
304- self . execute ( & properties_insert , query_args, None ) . await ?;
307+ self . execute ( & insert_stmt , query_args, None ) . await ?;
305308
306- Ok ( Namespace :: with_properties ( namespace. clone ( ) , properties) )
309+ Ok ( Namespace :: with_properties (
310+ namespace. clone ( ) ,
311+ insert_properties,
312+ ) )
307313 } else {
308314 // set a default property of exists = true
309- // up for debate if this is worthwhile
310315 self . execute (
311316 & insert,
312317 vec ! [
@@ -468,21 +473,8 @@ impl Catalog for SqlCatalog {
468473 }
469474 }
470475
471- async fn drop_namespace ( & self , namespace : & NamespaceIdent ) -> Result < ( ) > {
472- let exists = self . namespace_exists ( namespace) . await ?;
473- if exists {
474- // TODO: check that the namespace is empty
475- self . execute (
476- & format ! ( "DELETE FROM {NAMESPACE_TABLE_NAME} WHERE {NAMESPACE_FIELD_NAME} = ?" ) ,
477- vec ! [ Some ( & namespace. join( "." ) ) ] ,
478- None ,
479- )
480- . await ?;
481-
482- Ok ( ( ) )
483- } else {
484- no_such_namespace_err ( namespace)
485- }
476+ async fn drop_namespace ( & self , _namespace : & NamespaceIdent ) -> Result < ( ) > {
477+ todo ! ( )
486478 }
487479
488480 async fn list_tables ( & self , _namespace : & NamespaceIdent ) -> Result < Vec < TableIdent > > {
@@ -729,7 +721,7 @@ mod tests {
729721 let catalog = new_sql_catalog ( warehouse_loc) . await ;
730722 let namespace_ident = NamespaceIdent :: new ( "abc" . into ( ) ) ;
731723
732- let mut properties: HashMap < String , String > = HashMap :: new ( ) ;
724+ let mut properties = default_properties ( ) ;
733725 properties. insert ( "k" . into ( ) , "v" . into ( ) ) ;
734726
735727 assert_eq ! (
@@ -841,6 +833,7 @@ mod tests {
841833 }
842834
843835 #[ tokio:: test]
836+ #[ ignore = "drop_namespace not implemented" ]
844837 async fn test_drop_namespace ( ) {
845838 let warehouse_loc = temp_path ( ) ;
846839 let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -853,6 +846,7 @@ mod tests {
853846 }
854847
855848 #[ tokio:: test]
849+ #[ ignore = "drop_namespace not implemented" ]
856850 async fn test_drop_nested_namespace ( ) {
857851 let warehouse_loc = temp_path ( ) ;
858852 let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -871,6 +865,7 @@ mod tests {
871865 }
872866
873867 #[ tokio:: test]
868+ #[ ignore = "drop_namespace not implemented" ]
874869 async fn test_drop_deeply_nested_namespace ( ) {
875870 let warehouse_loc = temp_path ( ) ;
876871 let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -903,6 +898,7 @@ mod tests {
903898 }
904899
905900 #[ tokio:: test]
901+ #[ ignore = "drop_namespace not implemented" ]
906902 async fn test_drop_namespace_throws_error_if_namespace_doesnt_exist ( ) {
907903 let warehouse_loc = temp_path ( ) ;
908904 let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -922,6 +918,7 @@ mod tests {
922918 }
923919
924920 #[ tokio:: test]
921+ #[ ignore = "drop_namespace not implemented" ]
925922 async fn test_drop_namespace_throws_error_if_nested_namespace_doesnt_exist ( ) {
926923 let warehouse_loc = temp_path ( ) ;
927924 let catalog = new_sql_catalog ( warehouse_loc) . await ;
0 commit comments