singlestoredb 1.0.4__py3-none-any.whl → 1.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of singlestoredb might be problematic. Click here for more details.

Files changed (40) hide show
  1. singlestoredb/__init__.py +1 -1
  2. singlestoredb/config.py +131 -0
  3. singlestoredb/connection.py +3 -0
  4. singlestoredb/converters.py +390 -0
  5. singlestoredb/functions/dtypes.py +5 -198
  6. singlestoredb/functions/ext/__init__.py +0 -1
  7. singlestoredb/functions/ext/asgi.py +671 -153
  8. singlestoredb/functions/ext/json.py +2 -2
  9. singlestoredb/functions/ext/mmap.py +174 -67
  10. singlestoredb/functions/ext/rowdat_1.py +2 -2
  11. singlestoredb/functions/ext/utils.py +169 -0
  12. singlestoredb/fusion/handler.py +115 -9
  13. singlestoredb/fusion/handlers/stage.py +246 -13
  14. singlestoredb/fusion/handlers/workspace.py +417 -14
  15. singlestoredb/fusion/registry.py +86 -1
  16. singlestoredb/http/connection.py +40 -2
  17. singlestoredb/management/__init__.py +1 -0
  18. singlestoredb/management/organization.py +4 -0
  19. singlestoredb/management/utils.py +2 -2
  20. singlestoredb/management/workspace.py +79 -6
  21. singlestoredb/mysql/connection.py +81 -0
  22. singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
  23. singlestoredb/mysql/constants/FIELD_TYPE.py +16 -0
  24. singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
  25. singlestoredb/mysql/cursors.py +177 -4
  26. singlestoredb/mysql/protocol.py +50 -1
  27. singlestoredb/notebook/__init__.py +15 -0
  28. singlestoredb/notebook/_objects.py +212 -0
  29. singlestoredb/tests/test.sql +259 -0
  30. singlestoredb/tests/test_connection.py +1715 -133
  31. singlestoredb/tests/test_ext_func.py +2 -2
  32. singlestoredb/tests/test_ext_func_data.py +1 -1
  33. singlestoredb/utils/dtypes.py +205 -0
  34. singlestoredb/utils/results.py +367 -14
  35. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/METADATA +2 -1
  36. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/RECORD +40 -34
  37. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/LICENSE +0 -0
  38. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/WHEEL +0 -0
  39. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/entry_points.txt +0 -0
  40. {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/top_level.txt +0 -0
@@ -15,7 +15,34 @@ from .utils import get_workspace_manager
15
15
 
16
16
  class ShowRegionsHandler(SQLHandler):
17
17
  """
18
- SHOW REGIONS [ <like> ] [ <order-by> ] [ <limit> ];
18
+ SHOW REGIONS [ <like> ]
19
+ [ <order-by> ]
20
+ [ <limit> ];
21
+
22
+ Description
23
+ -----------
24
+ Returns a list of all the valid regions for the user.
25
+
26
+ Arguments
27
+ ---------
28
+ * ``<pattern>``: A pattern similar to SQL LIKE clause.
29
+ Uses ``%`` as the wildcard character.
30
+
31
+ Remarks
32
+ -------
33
+ * Use the ``LIKE`` clause to specify a pattern and return only the
34
+ regions that match the specified pattern.
35
+ * The ``LIMIT`` clause limits the number of results to the
36
+ specified number.
37
+ * Use the ``ORDER BY`` clause to sort the results by the specified
38
+ key. By default, the results are sorted in the ascending order.
39
+
40
+ Example
41
+ -------
42
+ The following command returns a list of all the regions in the US
43
+ and sorts the results in ascending order by their ``Name``::
44
+
45
+ SHOW REGIONS LIKE 'US%' ORDER BY Name;
19
46
 
20
47
  """
21
48
 
@@ -40,7 +67,40 @@ ShowRegionsHandler.register(overwrite=True)
40
67
 
41
68
  class ShowWorkspaceGroupsHandler(SQLHandler):
42
69
  """
43
- SHOW WORKSPACE GROUPS [ <like> ] [ <extended> ] [ <order-by> ] [ <limit> ];
70
+ SHOW WORKSPACE GROUPS [ <like> ]
71
+ [ <extended> ] [ <order-by> ]
72
+ [ <limit> ];
73
+
74
+ Description
75
+ -----------
76
+ Displays information on workspace groups.
77
+
78
+ Arguments
79
+ ---------
80
+ * ``<pattern>``: A pattern similar to SQL LIKE clause.
81
+ Uses ``%`` as the wildcard character.
82
+
83
+ Remarks
84
+ -------
85
+ * Use the ``LIKE`` clause to specify a pattern and return only the
86
+ workspace groups that match the specified pattern.
87
+ * The ``LIMIT`` clause limits the number of results to the
88
+ specified number.
89
+ * Use the ``ORDER BY`` clause to sort the results by the specified
90
+ key. By default, the results are sorted in the ascending order.
91
+ * To return more information about the workspace groups, use the
92
+ ``EXTENDED`` clause.
93
+
94
+ Example
95
+ -------
96
+ The following command displays a list of workspace groups with names
97
+ that match the specified pattern::
98
+
99
+ SHOW WORKSPACE GROUPS LIKE 'Marketing%' EXTENDED ORDER BY Name;
100
+
101
+ See Also
102
+ --------
103
+ * ``SHOW WORKSPACES``
44
104
 
45
105
  """
46
106
 
@@ -81,7 +141,9 @@ ShowWorkspaceGroupsHandler.register(overwrite=True)
81
141
 
82
142
  class ShowWorkspacesHandler(SQLHandler):
83
143
  """
84
- SHOW WORKSPACES [ in_group ] [ <like> ] [ <extended> ] [ <order-by> ] [ <limit> ];
144
+ SHOW WORKSPACES [ in_group ]
145
+ [ <like> ] [ <extended> ]
146
+ [ <order-by> ] [ <limit> ];
85
147
 
86
148
  # Workspace group
87
149
  in_group = IN GROUP { group_id | group_name }
@@ -92,6 +154,45 @@ class ShowWorkspacesHandler(SQLHandler):
92
154
  # Name of group
93
155
  group_name = '<group-name>'
94
156
 
157
+ Description
158
+ -----------
159
+ Displays information on workspaces in a workspace group.
160
+
161
+ Arguments
162
+ ---------
163
+ * ``<group_id>``: The ID of the workspace group that contains
164
+ the workspace.
165
+ * ``<group_name>``: The name of the workspace group that
166
+ contains the workspace.
167
+ * ``<pattern>``: A pattern similar to SQL LIKE clause.
168
+ Uses ``%`` as the wildcard character.
169
+
170
+ Remarks
171
+ -------
172
+ * The ``IN GROUP`` clause specifies the ID or the name of the
173
+ workspace group that contains the workspace.
174
+ * Use the ``LIKE`` clause to specify a pattern and return only
175
+ the workspaces that match the specified pattern.
176
+ * The ``LIMIT`` clause limits the number of results to the
177
+ specified number.
178
+ * Use the ``ORDER BY`` clause to sort the results by the
179
+ specified key. By default, the results are sorted in the
180
+ ascending order.
181
+ * To return more information about the workspaces, use the
182
+ ``EXTENDED`` clause.
183
+
184
+ Example
185
+ -------
186
+ The following command displays information on all the workspaces
187
+ in a workspace group named **wsg1** and sorts the results by
188
+ workspace name in the ascending order::
189
+
190
+ SHOW WORKSPACES IN GROUP 'wsg1' EXTENDED ORDER BY Name;
191
+
192
+ See Also
193
+ --------
194
+ * ``SHOW WORKSPACE GROUPS``
195
+
95
196
  """
96
197
 
97
198
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
@@ -136,6 +237,11 @@ class CreateWorkspaceGroupHandler(SQLHandler):
136
237
  [ with_password ]
137
238
  [ expires_at ]
138
239
  [ with_firewall_ranges ]
240
+ [ with_backup_bucket_kms_key_id ]
241
+ [ with_data_bucket_kms_key_id ]
242
+ [ with_smart_dr ]
243
+ [ allow_all_traffic ]
244
+ [ with_update_window ]
139
245
  ;
140
246
 
141
247
  # Only create workspace group if it doesn't exist already
@@ -159,6 +265,78 @@ class CreateWorkspaceGroupHandler(SQLHandler):
159
265
  # Incoming IP ranges
160
266
  with_firewall_ranges = WITH FIREWALL RANGES '<ip-range>',...
161
267
 
268
+ # Backup bucket key
269
+ with_backup_bucket_kms_key_id = WITH BACKUP BUCKET KMS KEY ID '<key-id>'
270
+
271
+ # Data bucket key
272
+ with_data_bucket_kms_key_id = WITH DATA BUCKET KMS KEY ID '<key-id>'
273
+
274
+ # Smart DR
275
+ with_smart_dr = WITH SMART DR
276
+
277
+ # Allow all incoming traffic
278
+ allow_all_traffic = ALLOW ALL TRAFFIC
279
+
280
+ # Update window
281
+ with_update_window = WITH UPDATE WINDOW '<day>:<hour>'
282
+
283
+ Description
284
+ -----------
285
+ Creates a workspace group.
286
+
287
+ Arguments
288
+ ---------
289
+ * ``<group-name>``: The name of the workspace group.
290
+ * ``<region_id>`` or ``<region_name>``: The ID or the name of the region
291
+ in which the new workspace group is created.
292
+ * ``<password>``: The admin password of the workspace group.
293
+ The password must contain:
294
+ - At least 8 characters
295
+ - At least one uppercase character
296
+ - At least one lowercase character
297
+ - At least one number or special character
298
+ * ``<expiry_time>``: The timestamp of when the workspace group terminates.
299
+ Expiration time can be specified as a timestamp or duration.
300
+ * ``<ip_range>``: A list of allowed IP addresses or CIDR ranges.
301
+ * ``<backup_key_id>``: The KMS key ID associated with the backup bucket.
302
+ * ``<data_key_id>``: The KMS key ID associated with the data bucket.
303
+ * ``<day>:<hour>``: The day of the week (0-6) and the hour of the day
304
+ (0-23) when the engine updates are applied to the workspace group.
305
+
306
+ Remarks
307
+ -------
308
+ * Specify the ``IF NOT EXISTS`` clause to create a new workspace group only
309
+ if a workspace group with the specified name does not exist.
310
+ * If the ``WITH BACKUP BUCKET KMS KEY ID '<backup_key_id>'`` clause is
311
+ specified, Customer-Managed Encryption Keys (CMEK) encryption is enabled
312
+ for the data bucket of the workspace group.
313
+ * If the ``WITH DATA BUCKET KMS KEY ID '<data_key_id>'`` clause is specified,
314
+ CMEK encryption for the data bucket and Amazon Elastic Block Store (EBS)
315
+ volumes of the workspace group is enabled.
316
+ * To enable Smart Disaster Recovery (SmartDR) for the workspace group, specify
317
+ the WITH SMART DR clause. Refer to Smart Disaster Recovery (DR):
318
+ SmartDR for more information.
319
+ * To allow incoming traffic from any IP address, use the ``ALLOW ALL TRAFFIC``
320
+ clause.
321
+
322
+ Examples
323
+ --------
324
+ The following command creates a workspace group named wsg1 in the
325
+ US East 2 (Ohio) region::
326
+
327
+ CREATE WORKSPACE GROUP 'wsg1' IN REGION 'US East 2 (Ohio)';
328
+
329
+ The following command specifies additional workspace group configuration
330
+ options::
331
+
332
+ CREATE WORKSPACE GROUP 'wsg1'
333
+ IN REGION ID '93b61160-0000-1000-9000-977b8e2e3ee5'
334
+ WITH FIREWALL RANGES '0.0.0.0/0';
335
+
336
+ See Also
337
+ --------
338
+ * ``SHOW WORKSPACE GROUPS``
339
+
162
340
  """
163
341
 
164
342
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
@@ -185,12 +363,22 @@ class CreateWorkspaceGroupHandler(SQLHandler):
185
363
  else:
186
364
  region_id = params['region_id']
187
365
 
366
+ with_update_window = None
367
+ if params['with_update_window']:
368
+ day, hour = params['with_update_window'].split(':', 1)
369
+ with_update_window = dict(day=int(day), hour=int(hour))
370
+
188
371
  manager.create_workspace_group(
189
372
  params['group_name'],
190
373
  region=region_id,
191
374
  admin_password=params['with_password'],
192
375
  expires_at=params['expires_at'],
193
376
  firewall_ranges=params['with_firewall_ranges'],
377
+ backup_bucket_kms_key_id=params['with_backup_bucket_kms_key_id'],
378
+ data_bucket_kms_key_id=params['with_data_bucket_kms_key_id'],
379
+ smart_dr=params['with_smart_dr'],
380
+ allow_all_traffic=params['allow_all_traffic'],
381
+ update_window=with_update_window,
194
382
  )
195
383
 
196
384
  return None
@@ -201,8 +389,13 @@ CreateWorkspaceGroupHandler.register(overwrite=True)
201
389
 
202
390
  class CreateWorkspaceHandler(SQLHandler):
203
391
  """
204
- CREATE WORKSPACE [ if_not_exists ] workspace_name [ in_group ]
205
- WITH SIZE size [ wait_on_active ];
392
+ CREATE WORKSPACE [ if_not_exists ] workspace_name
393
+ [ in_group ]
394
+ WITH SIZE size
395
+ [ auto_suspend ]
396
+ [ enable_kai ]
397
+ [ with_cache_config ]
398
+ [ wait_on_active ];
206
399
 
207
400
  # Create workspace in workspace group
208
401
  in_group = IN GROUP { group_id | group_name }
@@ -222,10 +415,63 @@ class CreateWorkspaceHandler(SQLHandler):
222
415
  # Runtime size
223
416
  size = '<size>'
224
417
 
418
+ # Auto-suspend
419
+ auto_suspend = AUTO SUSPEND suspend_after_seconds SECONDS suspend_type
420
+ suspend_after_seconds = AFTER <integer>
421
+ suspend_type = WITH TYPE { IDLE | SCHEDULED | DISABLED }
422
+
423
+ # Enable Kai
424
+ enable_kai = ENABLE KAI
425
+
426
+ # Cache config
427
+ with_cache_config = WITH CACHE CONFIG <integer>
428
+
225
429
  # Wait for workspace to be active before continuing
226
430
  wait_on_active = WAIT ON ACTIVE
227
431
 
228
- """
432
+ Description
433
+ -----------
434
+ Creates a new workspace. Refer to
435
+ `Creating and Using Workspaces <https://docs.singlestore.com/cloud/getting-started-with-singlestore-helios/about-workspaces/creating-and-using-workspaces/>`_
436
+ for more information.
437
+
438
+ Arguments
439
+ ---------
440
+ * ``<workspace_name>``: The name of the workspace.
441
+ * ``<group_id>`` or ``<group_name>``: The ID or name of the workspace group
442
+ in which the workspace is created.
443
+ * ``<workspace_size>``: The size of the workspace in workspace size notation,
444
+ for example "S-1".
445
+ * ``<suspend_time>``: The time (in seconds) after which the workspace is
446
+ suspended, according to the specified auto-suspend type.
447
+ * ``<multiplier>``: The multiplier for the persistent cache associated with
448
+ the workspace.
449
+
450
+ Remarks
451
+ -------
452
+ * Use the ``IF NOT EXISTS`` clause to create a new workspace only if a workspace
453
+ with the specified name does not exist.
454
+ * If the ``WITH CACHE CONFIG <multiplier>`` clause is specified, the cache
455
+ configuration multiplier is enabled for the workspace. It can have the
456
+ following values: 1, 2, or 4.
457
+ * The ``WAIT ON ACTIVE`` clause indicates that the execution is paused until this
458
+ workspace is in ACTIVE state.
459
+ * Specify the ``ENABLE KAI`` clause to enable SingleStore Kai and the MongoDB®
460
+ API for the workspace.
461
+
462
+ Example
463
+ -------
464
+ The following command creates a workspace named **examplews** in a workspace
465
+ group named **wsg1**::
466
+
467
+ CREATE WORKSPACE 'examplews' IN GROUP 'wsgroup1'
468
+ WITH SIZE 'S-00' WAIT ON ACTIVE;
469
+
470
+ See Also
471
+ --------
472
+ * ``CREATE WORKSPACE GROUP``
473
+
474
+ """ # noqa: E501
229
475
 
230
476
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
231
477
  workspace_group = get_workspace_group(params)
@@ -238,8 +484,19 @@ class CreateWorkspaceHandler(SQLHandler):
238
484
  except KeyError:
239
485
  pass
240
486
 
487
+ auto_suspend = None
488
+ if params['auto_suspend']:
489
+ auto_suspend = dict(
490
+ suspend_after_seconds=params['auto_suspend'][0]['suspend_after_seconds'],
491
+ suspend_type=params['auto_suspend'][-1]['suspend_type'].upper(),
492
+ )
493
+
241
494
  workspace_group.create_workspace(
242
- params['workspace_name'], size=params['size'],
495
+ params['workspace_name'],
496
+ size=params['size'],
497
+ auto_suspend=auto_suspend,
498
+ enable_kai=params['enable_kai'],
499
+ cache_config=params['with_cache_config'],
243
500
  wait_on_active=params['wait_on_active'],
244
501
  )
245
502
 
@@ -251,7 +508,9 @@ CreateWorkspaceHandler.register(overwrite=True)
251
508
 
252
509
  class SuspendWorkspaceHandler(SQLHandler):
253
510
  """
254
- SUSPEND WORKSPACE workspace [ in_group ] [ wait_on_suspended ];
511
+ SUSPEND WORKSPACE workspace
512
+ [ in_group ]
513
+ [ wait_on_suspended ];
255
514
 
256
515
  # Workspace
257
516
  workspace = { workspace_id | workspace_name }
@@ -274,7 +533,39 @@ class SuspendWorkspaceHandler(SQLHandler):
274
533
  # Wait for workspace to be suspended before continuing
275
534
  wait_on_suspended = WAIT ON SUSPENDED
276
535
 
277
- """
536
+ Description
537
+ -----------
538
+ Suspends a workspace.
539
+
540
+ Refer to `Manage Workspaces <https://docs.singlestore.com/cloud/user-and-workspace-administration/manage-organizations/manage-workspaces/>`_
541
+ for more information.
542
+
543
+ Arguments
544
+ ---------
545
+ * ``<workspace-id>``: The ID of the workspace to suspend.
546
+ * ``<workspace-name>``: The name of the workspace to suspend.
547
+ * ``<group-id>``: The ID of the workspace group that contains
548
+ the workspace.
549
+ * ``<group-name>``: The name of the workspace group that
550
+ contains the workspace.
551
+
552
+ Remarks
553
+ -------
554
+ * Use the ``WAIT ON SUSPENDED`` clause to pause query execution
555
+ until the workspace is in the ``SUSPENDED`` state.
556
+
557
+ Example
558
+ -------
559
+ The following example suspends a workspace named examplews in
560
+ a workspace group named **wsg1**::
561
+
562
+ SUSPEND WORKSPACE 'examplews' IN GROUP 'wsg1';
563
+
564
+ See Also
565
+ --------
566
+ * ``RESUME WORKSPACE``
567
+
568
+ """ # noqa: E501
278
569
 
279
570
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
280
571
  ws = get_workspace(params)
@@ -287,7 +578,10 @@ SuspendWorkspaceHandler.register(overwrite=True)
287
578
 
288
579
  class ResumeWorkspaceHandler(SQLHandler):
289
580
  """
290
- RESUME WORKSPACE workspace [ in_group ] [ wait_on_resumed ];
581
+ RESUME WORKSPACE workspace
582
+ [ in_group ]
583
+ [ disable_auto_suspend ]
584
+ [ wait_on_resumed ];
291
585
 
292
586
  # Workspace
293
587
  workspace = { workspace_id | workspace_name }
@@ -307,14 +601,53 @@ class ResumeWorkspaceHandler(SQLHandler):
307
601
  # Name of workspace group
308
602
  group_name = '<group-name>'
309
603
 
604
+ # Disable auto-suspend
605
+ disable_auto_suspend = DISABLE AUTO SUSPEND
606
+
310
607
  # Wait for workspace to be resumed before continuing
311
608
  wait_on_resumed = WAIT ON RESUMED
312
609
 
313
- """
610
+ Description
611
+ -----------
612
+ Resumes a workspace.
613
+
614
+ Refer to `Manage Workspaces <https://docs.singlestore.com/cloud/user-and-workspace-administration/manage-organizations/manage-workspaces/>`_
615
+ for more information.
616
+
617
+ Arguments
618
+ ---------
619
+ * ``<workspace-id>``: The ID of the workspace to resume.
620
+ * ``<workspace-name>``: The name of the workspace to resume.
621
+ * ``<group_id>``: The ID of the workspace group that contains
622
+ the workspace.
623
+ * ``<group_name>``: The name of the workspace group that
624
+ contains the workspace.
625
+
626
+ Remarks
627
+ -------
628
+ * Use the ``IN GROUP`` clause to specify the ID or name of the
629
+ workspace group that contains the workspace to resume.
630
+ * Use the ``WAIT ON RESUMED`` clause to pause query execution
631
+ until the workspace is in the ``RESUMED`` state.
632
+ * Specify the ``DISABLE AUTO SUSPEND`` clause to disable
633
+ auto-suspend for the resumed workspace.
634
+
635
+ Example
636
+ -------
637
+ The following example resumes a workspace with the specified ID
638
+ in a workspace group named **wsg1**::
639
+
640
+ RESUME WORKSPACE ID '93b61160-0000-1000-9000-977b8e2e3ee5'
641
+ IN GROUP 'wsg1';
642
+
643
+ """ # noqa: E501
314
644
 
315
645
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
316
646
  ws = get_workspace(params)
317
- ws.resume(wait_on_resumed=params['wait_on_resumed'])
647
+ ws.resume(
648
+ wait_on_resumed=params['wait_on_resumed'],
649
+ disable_auto_suspend=params['disable_auto_suspend'],
650
+ )
318
651
  return None
319
652
 
320
653
 
@@ -323,7 +656,10 @@ ResumeWorkspaceHandler.register(overwrite=True)
323
656
 
324
657
  class DropWorkspaceGroupHandler(SQLHandler):
325
658
  """
326
- DROP WORKSPACE GROUP [ if_exists ] group [ wait_on_terminated ] [ force ];
659
+ DROP WORKSPACE GROUP [ if_exists ]
660
+ group
661
+ [ wait_on_terminated ]
662
+ [ force ];
327
663
 
328
664
  # Only run command if the workspace group exists
329
665
  if_exists = IF EXISTS
@@ -343,6 +679,35 @@ class DropWorkspaceGroupHandler(SQLHandler):
343
679
  # Should the workspace group be terminated even if it has workspaces?
344
680
  force = FORCE
345
681
 
682
+ Description
683
+ -----------
684
+ Deletes the specified workspace group.
685
+
686
+ Arguments
687
+ ---------
688
+ * ``<group_id>``: The ID of the workspace group to delete.
689
+ * ``<group_name>``: The name of the workspace group to delete.
690
+
691
+ Remarks
692
+ -------
693
+ * Specify the ``IF EXISTS`` clause to attempt the delete operation
694
+ only if a workspace group with the specified ID or name exists.
695
+ * Use the ``WAIT ON TERMINATED`` clause to pause query execution until
696
+ the workspace group is in the ``TERMINATED`` state.
697
+ * If the ``FORCE`` clause is specified, the workspace group is
698
+ terminated even if it contains workspaces.
699
+
700
+ Example
701
+ -------
702
+ The following command deletes a workspace group named **wsg1** even
703
+ if it contains workspaces::
704
+
705
+ DROP WORKSPACE GROUP 'wsg1' FORCE;
706
+
707
+ See Also
708
+ --------
709
+ * ``DROP WORKSPACE``
710
+
346
711
  """
347
712
 
348
713
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
@@ -367,7 +732,10 @@ DropWorkspaceGroupHandler.register(overwrite=True)
367
732
 
368
733
  class DropWorkspaceHandler(SQLHandler):
369
734
  """
370
- DROP WORKSPACE [ if_exists ] workspace [ in_group ] [ wait_on_terminated ];
735
+ DROP WORKSPACE [ if_exists ]
736
+ workspace
737
+ [ in_group ]
738
+ [ wait_on_terminated ];
371
739
 
372
740
  # Only drop workspace if it exists
373
741
  if_exists = IF EXISTS
@@ -393,6 +761,41 @@ class DropWorkspaceHandler(SQLHandler):
393
761
  # Wait for workspace to be terminated before continuing
394
762
  wait_on_terminated = WAIT ON TERMINATED
395
763
 
764
+ Description
765
+ -----------
766
+ Deletes a workspace.
767
+
768
+ Arguments
769
+ ---------
770
+ * ``<workspace-id>``: The ID of the workspace to delete.
771
+ * ``<workspace-name>``: The name of the workspace to delete.
772
+ * ``<group_id>``: The ID of the workspace group that contains
773
+ the workspace.
774
+ * ``<group_name>``: The name of the workspace group that
775
+ contains the workspace.
776
+
777
+ Remarks
778
+ -------
779
+ * Specify the ``IF EXISTS`` clause to attempt the delete operation
780
+ only if a workspace with the specified ID or name exists.
781
+ * Use the ``IN GROUP`` clause to specify the ID or name of the workspace
782
+ group that contains the workspace to delete.
783
+ * Use the ``WAIT ON TERMINATED`` clause to pause query execution until
784
+ the workspace is in the ``TERMINATED`` state.
785
+ * All databases attached to the workspace are detached when the
786
+ workspace is deleted (terminated).
787
+
788
+ Example
789
+ -------
790
+ The following example deletes a workspace named **examplews** in
791
+ a workspace group **wsg1**::
792
+
793
+ DROP WORKSPACE IF EXISTS 'examplews' IN GROUP 'wsg1';
794
+
795
+ See Also
796
+ --------
797
+ * ``DROP WORKSPACE GROUP``
798
+
396
799
  """
397
800
 
398
801
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
  import re
3
+ import sys
3
4
  from typing import Any
4
5
  from typing import Dict
5
6
  from typing import List
@@ -120,6 +121,31 @@ class ShowFusionCommandsHandler(SQLHandler):
120
121
  # LIKE pattern
121
122
  like = LIKE '<pattern>'
122
123
 
124
+ Description
125
+ -----------
126
+ Displays a list of all the Fusion commands.
127
+
128
+ Arguments
129
+ ---------
130
+ * `<pattern>``: A pattern similar to SQL LIKE clause. Uses ``%`` as
131
+ the wildcard character.
132
+
133
+ Remarks
134
+ -------
135
+ * Use the ``LIKE`` clause to specify a pattern and return only the
136
+ commands that match the specified pattern.
137
+
138
+ Example
139
+ -------
140
+ The following command returns all the Fusion commands that start
141
+ with 'SHOW'::
142
+
143
+ SHOW FUSION COMMANDS LIKE 'SHOW%'
144
+
145
+ See Also
146
+ --------
147
+ * ``SHOW FUSION HELP``
148
+
123
149
  """
124
150
 
125
151
  def run(self, params: Dict[str, Any]) -> Optional[result.FusionSQLResult]:
@@ -128,7 +154,7 @@ class ShowFusionCommandsHandler(SQLHandler):
128
154
 
129
155
  data: List[Tuple[Any, ...]] = []
130
156
  for _, v in sorted(_handlers.items()):
131
- data.append((v.help.lstrip(),))
157
+ data.append((v.syntax.lstrip(),))
132
158
 
133
159
  res.set_rows(data)
134
160
 
@@ -148,6 +174,21 @@ class ShowFusionGrammarHandler(SQLHandler):
148
174
  # Query to show grammar for
149
175
  for_query = FOR '<query>'
150
176
 
177
+ Description
178
+ -----------
179
+ Show the full grammar of a Fusion SQL command for a given query.
180
+
181
+ Arguments
182
+ ---------
183
+ * ``<command>``: A Fusion command.
184
+
185
+ Example
186
+ -------
187
+ The following command displays the grammar for the
188
+ ``CREATE WORKSPACE`` Fusion command::
189
+
190
+ SHOW FUSION GRAMMAR FOR 'CREATE WORKSPACE';
191
+
151
192
  """
152
193
 
153
194
  def run(self, params: Dict[str, Any]) -> Optional[result.FusionSQLResult]:
@@ -162,3 +203,47 @@ class ShowFusionGrammarHandler(SQLHandler):
162
203
 
163
204
 
164
205
  ShowFusionGrammarHandler.register()
206
+
207
+
208
+ class ShowFusionHelpHandler(SQLHandler):
209
+ """
210
+ SHOW FUSION HELP for_command;
211
+
212
+ # Command to show help for
213
+ for_command = FOR '<command>'
214
+
215
+ Description
216
+ -----------
217
+ Displays the documentation for a Fusion command.
218
+
219
+ Arguments
220
+ ---------
221
+ * ``<command>``: A Fusion command.
222
+
223
+ Example
224
+ -------
225
+ The following command displays the documentation for
226
+ the ``CREATE WORKSPACE`` Fusion command.
227
+
228
+ SHOW FUSION HELP FOR 'CREATE WORKSPACE';
229
+
230
+ """
231
+
232
+ def run(self, params: Dict[str, Any]) -> Optional[result.FusionSQLResult]:
233
+ handler = get_handler(params['for_command'])
234
+ if handler is not None:
235
+ try:
236
+ from IPython.display import display
237
+ from IPython.display import Markdown
238
+ display(Markdown(handler.help))
239
+ except Exception:
240
+ print(handler.help)
241
+ else:
242
+ print(
243
+ f'No handler found for command \'{params["for_command"]}\'',
244
+ file=sys.stderr,
245
+ )
246
+ return None
247
+
248
+
249
+ ShowFusionHelpHandler.register()