singlestoredb 1.5.0__cp38-abi3-win32.whl → 1.6.0__cp38-abi3-win32.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.

@@ -18,7 +18,7 @@ class UseWorkspaceHandler(SQLHandler):
18
18
  USE WORKSPACE workspace [ with_database ];
19
19
 
20
20
  # Workspace
21
- workspace = { workspace_id | workspace_name }
21
+ workspace = { workspace_id | workspace_name | current_workspace }
22
22
 
23
23
  # ID of workspace
24
24
  workspace_id = ID '<workspace-id>'
@@ -26,6 +26,9 @@ class UseWorkspaceHandler(SQLHandler):
26
26
  # Name of workspace
27
27
  workspace_name = '<workspace-name>'
28
28
 
29
+ # Current workspace
30
+ current_workspace = @@CURRENT
31
+
29
32
  # Name of database
30
33
  with_database = WITH DATABASE 'database-name'
31
34
 
@@ -40,6 +43,8 @@ class UseWorkspaceHandler(SQLHandler):
40
43
 
41
44
  Remarks
42
45
  -------
46
+ * If you want to specify a database in the current workspace,
47
+ the workspace name can be specified as ``@@CURRENT``.
43
48
  * Specify the ``WITH DATABASE`` clause to select a default
44
49
  database for the session.
45
50
  * This command only works in a notebook session in the
@@ -55,11 +60,20 @@ class UseWorkspaceHandler(SQLHandler):
55
60
  """
56
61
  def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
57
62
  from singlestoredb.notebook import portal
58
- if params.get('with_database'):
59
- portal.connection = params['workspace']['workspace_name'], \
60
- params['with_database']
61
- else:
63
+ if params['workspace'].get('current_workspace'):
64
+ if params.get('with_database'):
65
+ portal.default_database = params['with_database']
66
+ elif params.get('with_database'):
67
+ if params['workspace'].get('workspace_name'):
68
+ portal.connection = params['workspace']['workspace_name'], \
69
+ params['with_database']
70
+ else:
71
+ portal.connection = params['workspace']['workspace_id'], \
72
+ params['with_database']
73
+ elif params['workspace'].get('workspace_name'):
62
74
  portal.workspace = params['workspace']['workspace_name']
75
+ else:
76
+ portal.workspace = params['workspace']['workspace_id']
63
77
  return None
64
78
 
65
79
 
@@ -469,8 +483,9 @@ class CreateWorkspaceHandler(SQLHandler):
469
483
  size = '<size>'
470
484
 
471
485
  # Auto-suspend
472
- auto_suspend = AUTO SUSPEND suspend_after_seconds SECONDS suspend_type
473
- suspend_after_seconds = AFTER <integer>
486
+ auto_suspend = AUTO SUSPEND AFTER suspend_after_value suspend_after_units suspend_type
487
+ suspend_after_value = <integer>
488
+ suspend_after_units = { SECONDS | MINUTES | HOURS | DAYS }
474
489
  suspend_type = WITH TYPE { IDLE | SCHEDULED | DISABLED }
475
490
 
476
491
  # Enable Kai
@@ -495,7 +510,7 @@ class CreateWorkspaceHandler(SQLHandler):
495
510
  in which the workspace is created.
496
511
  * ``<workspace_size>``: The size of the workspace in workspace size notation,
497
512
  for example "S-1".
498
- * ``<suspend_time>``: The time (in seconds) after which the workspace is
513
+ * ``<suspend_time>``: The time (in given units) after which the workspace is
499
514
  suspended, according to the specified auto-suspend type.
500
515
  * ``<multiplier>``: The multiplier for the persistent cache associated with
501
516
  the workspace.
@@ -539,9 +554,17 @@ class CreateWorkspaceHandler(SQLHandler):
539
554
 
540
555
  auto_suspend = None
541
556
  if params['auto_suspend']:
557
+ mult = dict(
558
+ SECONDS=1,
559
+ MINUTES=60,
560
+ HOURS=60*60,
561
+ DAYS=60*60*24,
562
+ )
563
+ val = params['auto_suspend'][0]['suspend_after_value']
564
+ val = val * mult[params['auto_suspend'][1]['suspend_after_units'].upper()]
542
565
  auto_suspend = dict(
543
- suspend_after_seconds=params['auto_suspend'][0]['suspend_after_seconds'],
544
- suspend_type=params['auto_suspend'][-1]['suspend_type'].upper(),
566
+ suspend_after_seconds=val,
567
+ suspend_type=params['auto_suspend'][2]['suspend_type'].upper(),
545
568
  )
546
569
 
547
570
  workspace_group.create_workspace(