@@ -287,26 +287,31 @@ impl Catalog for SqlCatalog {
287
287
"INSERT INTO {NAMESPACE_TABLE_NAME} ({CATALOG_FIELD_CATALOG_NAME}, {NAMESPACE_FIELD_NAME}, {NAMESPACE_FIELD_PROPERTY_KEY}, {NAMESPACE_FIELD_PROPERTY_VALUE})
288
288
VALUES (?, ?, ?, ?)" ) ;
289
289
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 ( ) {
293
296
query_args. extend_from_slice ( & [
294
297
Some ( self . name . as_str ( ) ) ,
295
298
Some ( namespace_str. as_str ( ) ) ,
296
299
Some ( key. as_str ( ) ) ,
297
300
Some ( value. as_str ( ) ) ,
298
301
] ) ;
299
302
if index > 0 {
300
- properties_insert = format ! ( "{properties_insert} , (?, ?, ?, ?)") ;
303
+ insert_stmt . push_str ( " , (?, ?, ?, ?)") ;
301
304
}
302
305
}
303
306
304
- self . execute ( & properties_insert , query_args, None ) . await ?;
307
+ self . execute ( & insert_stmt , query_args, None ) . await ?;
305
308
306
- Ok ( Namespace :: with_properties ( namespace. clone ( ) , properties) )
309
+ Ok ( Namespace :: with_properties (
310
+ namespace. clone ( ) ,
311
+ insert_properties,
312
+ ) )
307
313
} else {
308
314
// set a default property of exists = true
309
- // up for debate if this is worthwhile
310
315
self . execute (
311
316
& insert,
312
317
vec ! [
@@ -468,21 +473,8 @@ impl Catalog for SqlCatalog {
468
473
}
469
474
}
470
475
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 ! ( )
486
478
}
487
479
488
480
async fn list_tables ( & self , _namespace : & NamespaceIdent ) -> Result < Vec < TableIdent > > {
@@ -729,7 +721,7 @@ mod tests {
729
721
let catalog = new_sql_catalog ( warehouse_loc) . await ;
730
722
let namespace_ident = NamespaceIdent :: new ( "abc" . into ( ) ) ;
731
723
732
- let mut properties: HashMap < String , String > = HashMap :: new ( ) ;
724
+ let mut properties = default_properties ( ) ;
733
725
properties. insert ( "k" . into ( ) , "v" . into ( ) ) ;
734
726
735
727
assert_eq ! (
@@ -841,6 +833,7 @@ mod tests {
841
833
}
842
834
843
835
#[ tokio:: test]
836
+ #[ ignore = "drop_namespace not implemented" ]
844
837
async fn test_drop_namespace ( ) {
845
838
let warehouse_loc = temp_path ( ) ;
846
839
let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -853,6 +846,7 @@ mod tests {
853
846
}
854
847
855
848
#[ tokio:: test]
849
+ #[ ignore = "drop_namespace not implemented" ]
856
850
async fn test_drop_nested_namespace ( ) {
857
851
let warehouse_loc = temp_path ( ) ;
858
852
let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -871,6 +865,7 @@ mod tests {
871
865
}
872
866
873
867
#[ tokio:: test]
868
+ #[ ignore = "drop_namespace not implemented" ]
874
869
async fn test_drop_deeply_nested_namespace ( ) {
875
870
let warehouse_loc = temp_path ( ) ;
876
871
let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -903,6 +898,7 @@ mod tests {
903
898
}
904
899
905
900
#[ tokio:: test]
901
+ #[ ignore = "drop_namespace not implemented" ]
906
902
async fn test_drop_namespace_throws_error_if_namespace_doesnt_exist ( ) {
907
903
let warehouse_loc = temp_path ( ) ;
908
904
let catalog = new_sql_catalog ( warehouse_loc) . await ;
@@ -922,6 +918,7 @@ mod tests {
922
918
}
923
919
924
920
#[ tokio:: test]
921
+ #[ ignore = "drop_namespace not implemented" ]
925
922
async fn test_drop_namespace_throws_error_if_nested_namespace_doesnt_exist ( ) {
926
923
let warehouse_loc = temp_path ( ) ;
927
924
let catalog = new_sql_catalog ( warehouse_loc) . await ;
0 commit comments