File tree 2 files changed +35
-2
lines changed
2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,23 @@ def version(ctx: Context) -> None:
206
206
ctx .obj ["output" ].version (__version__ )
207
207
208
208
209
+ @run .group ()
210
+ def create () -> None :
211
+ """Operation to create a namespace."""
212
+
213
+
214
+ @create .command ()
215
+ @click .argument ("identifier" )
216
+ @click .pass_context
217
+ @catch_exception ()
218
+ def namespace (ctx : Context , identifier : str ) -> None :
219
+ """Create a namespace."""
220
+ catalog , output = _catalog_and_output (ctx )
221
+
222
+ catalog .create_namespace (identifier )
223
+ output .text (f"Created namespace: { identifier } " )
224
+
225
+
209
226
@run .group ()
210
227
def drop () -> None :
211
228
"""Operations to drop a namespace or table."""
@@ -223,11 +240,11 @@ def table(ctx: Context, identifier: str) -> None: # noqa: F811
223
240
output .text (f"Dropped table: { identifier } " )
224
241
225
242
226
- @drop .command ()
243
+ @drop .command () # type: ignore
227
244
@click .argument ("identifier" )
228
245
@click .pass_context
229
246
@catch_exception ()
230
- def namespace (ctx : Context , identifier : str ) -> None :
247
+ def namespace (ctx : Context , identifier : str ) -> None : # noqa: F811
231
248
"""Drop a namespace."""
232
249
catalog , output = _catalog_and_output (ctx )
233
250
Original file line number Diff line number Diff line change @@ -308,6 +308,22 @@ def test_drop_namespace_does_not_exists(catalog: InMemoryCatalog) -> None:
308
308
assert result .output == "Namespace does not exist: ('doesnotexist',)\n "
309
309
310
310
311
+ def test_create_namespace (catalog : InMemoryCatalog ) -> None :
312
+ runner = CliRunner ()
313
+ result = runner .invoke (run , ["create" , "namespace" , TEST_TABLE_NAMESPACE ])
314
+ assert result .exit_code == 0
315
+ assert result .output == """Created namespace: default\n """
316
+
317
+
318
+ def test_create_namespace_already_exists (catalog : InMemoryCatalog ) -> None :
319
+ catalog .create_namespace (TEST_TABLE_NAMESPACE )
320
+
321
+ runner = CliRunner ()
322
+ result = runner .invoke (run , ["create" , "namespace" , TEST_TABLE_NAMESPACE ])
323
+ assert result .exit_code == 1
324
+ assert result .output == "Namespace already exists: ('default',)\n "
325
+
326
+
311
327
def test_rename_table (catalog : InMemoryCatalog ) -> None :
312
328
catalog .create_table (
313
329
identifier = TEST_TABLE_IDENTIFIER ,
You can’t perform that action at this time.
0 commit comments