singlestoredb 1.0.4__cp38-abi3-win32.whl → 1.2.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.
- _singlestoredb_accel.pyd +0 -0
- singlestoredb/__init__.py +1 -1
- singlestoredb/config.py +131 -0
- singlestoredb/connection.py +3 -0
- singlestoredb/converters.py +390 -0
- singlestoredb/functions/dtypes.py +5 -198
- singlestoredb/functions/ext/__init__.py +0 -1
- singlestoredb/functions/ext/asgi.py +671 -153
- singlestoredb/functions/ext/json.py +2 -2
- singlestoredb/functions/ext/mmap.py +174 -67
- singlestoredb/functions/ext/rowdat_1.py +2 -2
- singlestoredb/functions/ext/utils.py +169 -0
- singlestoredb/fusion/handler.py +115 -9
- singlestoredb/fusion/handlers/stage.py +246 -13
- singlestoredb/fusion/handlers/workspace.py +417 -14
- singlestoredb/fusion/registry.py +86 -1
- singlestoredb/http/connection.py +40 -2
- singlestoredb/management/__init__.py +1 -0
- singlestoredb/management/organization.py +4 -0
- singlestoredb/management/utils.py +2 -2
- singlestoredb/management/workspace.py +79 -6
- singlestoredb/mysql/connection.py +81 -0
- singlestoredb/mysql/constants/EXTENDED_TYPE.py +3 -0
- singlestoredb/mysql/constants/FIELD_TYPE.py +16 -0
- singlestoredb/mysql/constants/VECTOR_TYPE.py +6 -0
- singlestoredb/mysql/cursors.py +177 -4
- singlestoredb/mysql/protocol.py +50 -1
- singlestoredb/notebook/__init__.py +15 -0
- singlestoredb/notebook/_objects.py +212 -0
- singlestoredb/tests/test.sql +259 -0
- singlestoredb/tests/test_connection.py +1715 -133
- singlestoredb/tests/test_ext_func.py +2 -2
- singlestoredb/tests/test_ext_func_data.py +1 -1
- singlestoredb/utils/dtypes.py +205 -0
- singlestoredb/utils/results.py +367 -14
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/METADATA +2 -1
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/RECORD +41 -35
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/LICENSE +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/WHEEL +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/entry_points.txt +0 -0
- {singlestoredb-1.0.4.dist-info → singlestoredb-1.2.0.dist-info}/top_level.txt +0 -0
singlestoredb/fusion/handler.py
CHANGED
|
@@ -45,6 +45,8 @@ BUILTINS = {
|
|
|
45
45
|
'<limit>': r'''
|
|
46
46
|
limit = LIMIT <integer>
|
|
47
47
|
''',
|
|
48
|
+
'<integer>': '',
|
|
49
|
+
'<number>': '',
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
BUILTIN_DEFAULTS = { # type: ignore
|
|
@@ -170,8 +172,8 @@ def build_cmd(grammar: str) -> str:
|
|
|
170
172
|
return f'{space}{cmd} ={begin}\n{end}'
|
|
171
173
|
|
|
172
174
|
|
|
173
|
-
def
|
|
174
|
-
"""Construct full
|
|
175
|
+
def build_syntax(grammar: str) -> str:
|
|
176
|
+
"""Construct full syntax."""
|
|
175
177
|
if ';' not in grammar:
|
|
176
178
|
raise ValueError('a semi-colon exist at the end of the primary rule')
|
|
177
179
|
|
|
@@ -199,8 +201,102 @@ def build_help(grammar: str) -> str:
|
|
|
199
201
|
return cmd
|
|
200
202
|
|
|
201
203
|
|
|
204
|
+
def _format_examples(ex: str) -> str:
|
|
205
|
+
"""Convert examples into sections."""
|
|
206
|
+
return re.sub(r'(^Example\s+\d+.*$)', r'### \1', ex, flags=re.M)
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def _format_arguments(arg: str) -> str:
|
|
210
|
+
"""Format arguments as subsections."""
|
|
211
|
+
out = []
|
|
212
|
+
for line in arg.split('\n'):
|
|
213
|
+
if line.startswith('<'):
|
|
214
|
+
out.append(f'### {line.replace("<", "<").replace(">", ">")}')
|
|
215
|
+
out.append('')
|
|
216
|
+
else:
|
|
217
|
+
out.append(line.strip())
|
|
218
|
+
return '\n'.join(out)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _to_markdown(txt: str) -> str:
|
|
222
|
+
"""Convert formatting to markdown."""
|
|
223
|
+
txt = re.sub(r'`([^`]+)\s+\<([^\>]+)>`_', r'[\1](\2)', txt)
|
|
224
|
+
txt = txt.replace('``', '`')
|
|
225
|
+
|
|
226
|
+
# Format code blocks
|
|
227
|
+
lines = re.split(r'\n', txt)
|
|
228
|
+
out = []
|
|
229
|
+
while lines:
|
|
230
|
+
line = lines.pop(0)
|
|
231
|
+
if line.endswith('::'):
|
|
232
|
+
out.append(line[:-2] + '.')
|
|
233
|
+
code = []
|
|
234
|
+
while lines and (not lines[0].strip() or lines[0].startswith(' ')):
|
|
235
|
+
code.append(lines.pop(0).rstrip())
|
|
236
|
+
code_str = re.sub(r'^\s*\n', r'', '\n'.join(code).rstrip())
|
|
237
|
+
out.extend([f'```sql\n{code_str}\n```\n'])
|
|
238
|
+
else:
|
|
239
|
+
out.append(line)
|
|
240
|
+
|
|
241
|
+
return '\n'.join(out)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def build_help(syntax: str, grammar: str) -> str:
|
|
245
|
+
"""Build full help text."""
|
|
246
|
+
cmd = re.match(r'([A-Z0-9_ ]+)', syntax.strip())
|
|
247
|
+
if not cmd:
|
|
248
|
+
raise ValueError(f'no command found: {syntax}')
|
|
249
|
+
|
|
250
|
+
out = [f'# {cmd.group(1)}\n\n']
|
|
251
|
+
|
|
252
|
+
sections: Dict[str, str] = {}
|
|
253
|
+
grammar = textwrap.dedent(grammar.rstrip())
|
|
254
|
+
desc_re = re.compile(r'^([A-Z][\S ]+)\s*^\-\-\-\-+\s*$', flags=re.M)
|
|
255
|
+
if desc_re.search(grammar):
|
|
256
|
+
_, *txt = desc_re.split(grammar)
|
|
257
|
+
txt = [x.strip() for x in txt]
|
|
258
|
+
sections = {}
|
|
259
|
+
while txt:
|
|
260
|
+
key = txt.pop(0)
|
|
261
|
+
value = txt.pop(0)
|
|
262
|
+
sections[key.lower()] = _to_markdown(value).strip()
|
|
263
|
+
|
|
264
|
+
if 'description' in sections:
|
|
265
|
+
out.extend([sections['description'], '\n\n'])
|
|
266
|
+
|
|
267
|
+
out.append(f'## Syntax\n\n```sql{syntax}\n```\n\n')
|
|
268
|
+
|
|
269
|
+
if 'arguments' in sections:
|
|
270
|
+
out.extend([
|
|
271
|
+
'## Arguments\n\n',
|
|
272
|
+
_format_arguments(sections['arguments']),
|
|
273
|
+
'\n\n',
|
|
274
|
+
])
|
|
275
|
+
if 'argument' in sections:
|
|
276
|
+
out.extend([
|
|
277
|
+
'## Argument\n\n',
|
|
278
|
+
_format_arguments(sections['argument']),
|
|
279
|
+
'\n\n',
|
|
280
|
+
])
|
|
281
|
+
|
|
282
|
+
if 'remarks' in sections:
|
|
283
|
+
out.extend(['## Remarks\n\n', sections['remarks'], '\n\n'])
|
|
284
|
+
|
|
285
|
+
if 'examples' in sections:
|
|
286
|
+
out.extend(['## Examples\n\n', _format_examples(sections['examples']), '\n\n'])
|
|
287
|
+
elif 'example' in sections:
|
|
288
|
+
out.extend(['## Example\n\n', _format_examples(sections['example']), '\n\n'])
|
|
289
|
+
|
|
290
|
+
if 'see also' in sections:
|
|
291
|
+
out.extend(['## See Also\n\n', sections['see also'], '\n\n'])
|
|
292
|
+
|
|
293
|
+
return ''.join(out).rstrip() + '\n'
|
|
294
|
+
|
|
295
|
+
|
|
202
296
|
def strip_comments(grammar: str) -> str:
|
|
203
297
|
"""Strip comments from grammar."""
|
|
298
|
+
desc_re = re.compile(r'(^\s*Description\s*^\s*-----------\s*$)', flags=re.M)
|
|
299
|
+
grammar = desc_re.split(grammar, maxsplit=1)[0]
|
|
204
300
|
return re.sub(r'^\s*#.*$', r'', grammar, flags=re.M)
|
|
205
301
|
|
|
206
302
|
|
|
@@ -226,7 +322,9 @@ def inject_builtins(grammar: str) -> str:
|
|
|
226
322
|
return grammar
|
|
227
323
|
|
|
228
324
|
|
|
229
|
-
def process_grammar(
|
|
325
|
+
def process_grammar(
|
|
326
|
+
grammar: str,
|
|
327
|
+
) -> Tuple[Grammar, Tuple[str, ...], Dict[str, Any], str, str]:
|
|
230
328
|
"""
|
|
231
329
|
Convert SQL grammar to a Parsimonious grammar.
|
|
232
330
|
|
|
@@ -247,10 +345,12 @@ def process_grammar(grammar: str) -> Tuple[Grammar, Tuple[str, ...], Dict[str, A
|
|
|
247
345
|
rules = {}
|
|
248
346
|
rule_info = {}
|
|
249
347
|
|
|
348
|
+
full_grammar = grammar
|
|
250
349
|
grammar = strip_comments(grammar)
|
|
251
350
|
grammar = inject_builtins(grammar)
|
|
252
351
|
command_key = get_keywords(grammar)
|
|
253
|
-
|
|
352
|
+
syntax_txt = build_syntax(grammar)
|
|
353
|
+
help_txt = build_help(syntax_txt, full_grammar)
|
|
254
354
|
grammar = build_cmd(grammar)
|
|
255
355
|
|
|
256
356
|
# Make sure grouping characters all have whitespace around them
|
|
@@ -336,7 +436,10 @@ def process_grammar(grammar: str) -> Tuple[Grammar, Tuple[str, ...], Dict[str, A
|
|
|
336
436
|
cmds = ' / '.join(x for x in rules if x.endswith('_cmd'))
|
|
337
437
|
cmds = f'init = ws* ( {cmds} ) ws* ";"? ws*\n'
|
|
338
438
|
|
|
339
|
-
return
|
|
439
|
+
return (
|
|
440
|
+
Grammar(cmds + CORE_GRAMMAR + '\n'.join(out)), command_key,
|
|
441
|
+
rule_info, syntax_txt, help_txt,
|
|
442
|
+
)
|
|
340
443
|
|
|
341
444
|
|
|
342
445
|
def flatten(items: Iterable[Any]) -> List[Any]:
|
|
@@ -378,7 +481,10 @@ class SQLHandler(NodeVisitor):
|
|
|
378
481
|
#: Metadata about the parse rules
|
|
379
482
|
rule_info: Dict[str, Any] = {}
|
|
380
483
|
|
|
381
|
-
#:
|
|
484
|
+
#: Syntax string for use in error messages
|
|
485
|
+
syntax: str = ''
|
|
486
|
+
|
|
487
|
+
#: Full help for the command
|
|
382
488
|
help: str = ''
|
|
383
489
|
|
|
384
490
|
#: Rule validation functions
|
|
@@ -396,7 +502,7 @@ class SQLHandler(NodeVisitor):
|
|
|
396
502
|
Compile the grammar held in the docstring.
|
|
397
503
|
|
|
398
504
|
This method modifies attributes on the class: ``grammar``,
|
|
399
|
-
``command_key``, ``rule_info``, and ``help``.
|
|
505
|
+
``command_key``, ``rule_info``, ``syntax``, and ``help``.
|
|
400
506
|
|
|
401
507
|
Parameters
|
|
402
508
|
----------
|
|
@@ -407,7 +513,7 @@ class SQLHandler(NodeVisitor):
|
|
|
407
513
|
if cls._is_compiled:
|
|
408
514
|
return
|
|
409
515
|
|
|
410
|
-
cls.grammar, cls.command_key, cls.rule_info, cls.help = \
|
|
516
|
+
cls.grammar, cls.command_key, cls.rule_info, cls.syntax, cls.help = \
|
|
411
517
|
process_grammar(grammar or cls.__doc__ or '')
|
|
412
518
|
|
|
413
519
|
cls._grammar = grammar or cls.__doc__ or ''
|
|
@@ -476,7 +582,7 @@ class SQLHandler(NodeVisitor):
|
|
|
476
582
|
msg = ' ' + m.group(1) + m.group(2)
|
|
477
583
|
raise ValueError(
|
|
478
584
|
f'Could not parse statement.{msg} '
|
|
479
|
-
'Expecting:\n' + textwrap.indent(type(self).
|
|
585
|
+
'Expecting:\n' + textwrap.indent(type(self).syntax, ' '),
|
|
480
586
|
)
|
|
481
587
|
|
|
482
588
|
@abc.abstractmethod
|
|
@@ -12,8 +12,10 @@ from .utils import get_workspace_group
|
|
|
12
12
|
|
|
13
13
|
class ShowStageFilesHandler(SQLHandler):
|
|
14
14
|
"""
|
|
15
|
-
SHOW STAGE FILES [ in_group ]
|
|
16
|
-
|
|
15
|
+
SHOW STAGE FILES [ in_group ]
|
|
16
|
+
[ at_path ] [ <like> ]
|
|
17
|
+
[ <order-by> ]
|
|
18
|
+
[ <limit> ] [ recursive ] [ extended ];
|
|
17
19
|
|
|
18
20
|
# Workspace group
|
|
19
21
|
in_group = IN GROUP { group_id | group_name }
|
|
@@ -33,7 +35,56 @@ class ShowStageFilesHandler(SQLHandler):
|
|
|
33
35
|
# Should extended attributes be shown?
|
|
34
36
|
extended = EXTENDED
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
Description
|
|
39
|
+
-----------
|
|
40
|
+
Displays a list of files in a Stage.
|
|
41
|
+
|
|
42
|
+
Refer to `Stage <https://docs.singlestore.com/cloud/developer-resources/stage-storage-service/>`_
|
|
43
|
+
for more information.
|
|
44
|
+
|
|
45
|
+
Arguments
|
|
46
|
+
---------
|
|
47
|
+
* ``<group_id>``: The ID of the workspace group in which
|
|
48
|
+
the Stage is attached.
|
|
49
|
+
* ``<group_name>``: The name of the workspace group in which
|
|
50
|
+
the Stage is attached.
|
|
51
|
+
* ``<path>``: A path in the Stage.
|
|
52
|
+
* ``<pattern>``: A pattern similar to SQL LIKE clause.
|
|
53
|
+
Uses ``%`` as the wildcard character.
|
|
54
|
+
|
|
55
|
+
Remarks
|
|
56
|
+
-------
|
|
57
|
+
* Use the ``LIKE`` clause to specify a pattern and return only the
|
|
58
|
+
files that match the specified pattern.
|
|
59
|
+
* The ``LIMIT`` clause limits the number of results to the
|
|
60
|
+
specified number.
|
|
61
|
+
* Use the ``ORDER BY`` clause to sort the results by the specified
|
|
62
|
+
key. By default, the results are sorted in the ascending order.
|
|
63
|
+
* The ``AT PATH`` clause specifies the path in the Stage to list
|
|
64
|
+
the files from.
|
|
65
|
+
* The ``IN GROUP`` clause specifies the ID or the name of the
|
|
66
|
+
workspace group in which the Stage is attached.
|
|
67
|
+
* Use the ``RECURSIVE`` clause to list the files recursively.
|
|
68
|
+
* To return more information about the files, use the ``EXTENDED``
|
|
69
|
+
clause.
|
|
70
|
+
|
|
71
|
+
Examples
|
|
72
|
+
--------
|
|
73
|
+
The following command lists the files at a specific path::
|
|
74
|
+
|
|
75
|
+
SHOW STAGE FILES IN GROUP 'wsg1' AT PATH "/data/";
|
|
76
|
+
|
|
77
|
+
The following command lists the files recursively with
|
|
78
|
+
additional information::
|
|
79
|
+
|
|
80
|
+
SHOW STAGE FILES IN GROUP 'wsg1' RECURSIVE EXTENDED;
|
|
81
|
+
|
|
82
|
+
See Also
|
|
83
|
+
--------
|
|
84
|
+
* ``UPLOAD FILE TO STAGE``
|
|
85
|
+
* ``DOWNLOAD STAGE FILE``
|
|
86
|
+
|
|
87
|
+
""" # noqa: E501
|
|
37
88
|
|
|
38
89
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
39
90
|
wg = get_workspace_group(params)
|
|
@@ -80,7 +131,9 @@ ShowStageFilesHandler.register(overwrite=True)
|
|
|
80
131
|
|
|
81
132
|
class UploadStageFileHandler(SQLHandler):
|
|
82
133
|
"""
|
|
83
|
-
UPLOAD FILE TO STAGE stage_path
|
|
134
|
+
UPLOAD FILE TO STAGE stage_path
|
|
135
|
+
[ in_group ]
|
|
136
|
+
FROM local_path [ overwrite ];
|
|
84
137
|
|
|
85
138
|
# Path to stage file
|
|
86
139
|
stage_path = '<stage-path>'
|
|
@@ -100,7 +153,43 @@ class UploadStageFileHandler(SQLHandler):
|
|
|
100
153
|
# Should an existing file be overwritten?
|
|
101
154
|
overwrite = OVERWRITE
|
|
102
155
|
|
|
103
|
-
|
|
156
|
+
Description
|
|
157
|
+
-----------
|
|
158
|
+
Uploads a file to a Stage.
|
|
159
|
+
|
|
160
|
+
Refer to `Stage <https://docs.singlestore.com/cloud/developer-resources/stage-storage-service/>`_
|
|
161
|
+
for more information.
|
|
162
|
+
|
|
163
|
+
Arguments
|
|
164
|
+
---------
|
|
165
|
+
* ``<stage_path>``: The path in the Stage where the file is uploaded.
|
|
166
|
+
* ``<group_id>``: The ID of the workspace group in which the Stage
|
|
167
|
+
is attached.
|
|
168
|
+
* ``<group_name>``: The name of the workspace group in which the
|
|
169
|
+
Stage is attached.
|
|
170
|
+
* ``<local-path>``: The path to the file to upload in the local
|
|
171
|
+
directory.
|
|
172
|
+
|
|
173
|
+
Remarks
|
|
174
|
+
-------
|
|
175
|
+
* The ``IN GROUP`` clause specifies the ID or the name of the workspace
|
|
176
|
+
group in which the Stage is attached.
|
|
177
|
+
* If the ``OVERWRITE`` clause is specified, any existing file at the
|
|
178
|
+
specified path in the Stage is overwritten.
|
|
179
|
+
|
|
180
|
+
Examples
|
|
181
|
+
--------
|
|
182
|
+
The following command uploads a file to a Stage and overwrites any
|
|
183
|
+
existing files at the specified path::
|
|
184
|
+
|
|
185
|
+
UPLOAD FILE TO STAGE '/data/stats.csv' IN GROUP 'wsg1'
|
|
186
|
+
FROM '/tmp/user/stats.csv' OVERWRITE;
|
|
187
|
+
|
|
188
|
+
See Also
|
|
189
|
+
--------
|
|
190
|
+
* ``DOWNLOAD STAGE FILE``
|
|
191
|
+
|
|
192
|
+
""" # noqa: E501
|
|
104
193
|
|
|
105
194
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
106
195
|
wg = get_workspace_group(params)
|
|
@@ -116,8 +205,11 @@ UploadStageFileHandler.register(overwrite=True)
|
|
|
116
205
|
|
|
117
206
|
class DownloadStageFileHandler(SQLHandler):
|
|
118
207
|
"""
|
|
119
|
-
DOWNLOAD STAGE FILE stage_path
|
|
120
|
-
|
|
208
|
+
DOWNLOAD STAGE FILE stage_path
|
|
209
|
+
[ in_group ]
|
|
210
|
+
[ local_path ]
|
|
211
|
+
[ overwrite ]
|
|
212
|
+
[ encoding ];
|
|
121
213
|
|
|
122
214
|
# Path to stage file
|
|
123
215
|
stage_path = '<stage-path>'
|
|
@@ -140,7 +232,54 @@ class DownloadStageFileHandler(SQLHandler):
|
|
|
140
232
|
# File encoding
|
|
141
233
|
encoding = ENCODING '<encoding>'
|
|
142
234
|
|
|
143
|
-
|
|
235
|
+
Description
|
|
236
|
+
-----------
|
|
237
|
+
Download a file from a Stage.
|
|
238
|
+
|
|
239
|
+
Refer to `Stage <https://docs.singlestore.com/cloud/developer-resources/stage-storage-service/>`_
|
|
240
|
+
for more information.
|
|
241
|
+
|
|
242
|
+
Arguments
|
|
243
|
+
---------
|
|
244
|
+
* ``<stage_path>``: The path to the file to download in a Stage.
|
|
245
|
+
* ``<group_id>``: The ID of the workspace group in which the
|
|
246
|
+
Stage is attached.
|
|
247
|
+
* ``<group_name>``: The name of the workspace group in which the
|
|
248
|
+
Stage is attached.
|
|
249
|
+
* ``<encoding>``: The encoding to apply to the downloaded file.
|
|
250
|
+
* ``<local-path>``: Specifies the path in the local directory
|
|
251
|
+
where the file is downloaded.
|
|
252
|
+
|
|
253
|
+
Remarks
|
|
254
|
+
-------
|
|
255
|
+
* If the ``OVERWRITE`` clause is specified, any existing file at
|
|
256
|
+
the download location is overwritten.
|
|
257
|
+
* The ``IN GROUP`` clause specifies the ID or the name of the
|
|
258
|
+
workspace group in which the Stage is attached.
|
|
259
|
+
* By default, files are downloaded in binary encoding. To view
|
|
260
|
+
the contents of the file on the standard output, use the
|
|
261
|
+
``ENCODING`` clause and specify an encoding.
|
|
262
|
+
* If ``<local-path>`` is not specified, the file is displayed
|
|
263
|
+
on the standard output.
|
|
264
|
+
|
|
265
|
+
Examples
|
|
266
|
+
--------
|
|
267
|
+
The following command displays the contents of the file on the
|
|
268
|
+
standard output::
|
|
269
|
+
|
|
270
|
+
DOWNLOAD STAGE FILE '/data/stats.csv' IN GROUP 'wsgroup1' ENCODING 'utf8';
|
|
271
|
+
|
|
272
|
+
The following command downloads a file to a specific location and
|
|
273
|
+
overwrites any existing file with the name ``stats.csv`` on the local storage::
|
|
274
|
+
|
|
275
|
+
DOWNLOAD STAGE FILE '/data/stats.csv' IN GROUP 'wsgroup1'
|
|
276
|
+
TO '/tmp/data.csv' OVERWRITE;
|
|
277
|
+
|
|
278
|
+
See Also
|
|
279
|
+
--------
|
|
280
|
+
* ``UPLOAD FILE TO STAGE``
|
|
281
|
+
|
|
282
|
+
""" # noqa: E501
|
|
144
283
|
|
|
145
284
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
146
285
|
wg = get_workspace_group(params)
|
|
@@ -169,7 +308,8 @@ DownloadStageFileHandler.register(overwrite=True)
|
|
|
169
308
|
|
|
170
309
|
class DropStageFileHandler(SQLHandler):
|
|
171
310
|
"""
|
|
172
|
-
DROP STAGE FILE stage_path
|
|
311
|
+
DROP STAGE FILE stage_path
|
|
312
|
+
[ in_group ];
|
|
173
313
|
|
|
174
314
|
# Path to stage file
|
|
175
315
|
stage_path = '<stage-path>'
|
|
@@ -183,7 +323,38 @@ class DropStageFileHandler(SQLHandler):
|
|
|
183
323
|
# Name of group
|
|
184
324
|
group_name = '<group-name>'
|
|
185
325
|
|
|
186
|
-
|
|
326
|
+
Description
|
|
327
|
+
-----------
|
|
328
|
+
Deletes a file from a Stage.
|
|
329
|
+
|
|
330
|
+
Refer to `Stage <https://docs.singlestore.com/cloud/developer-resources/stage-storage-service/>`_
|
|
331
|
+
for more information.
|
|
332
|
+
|
|
333
|
+
Arguments
|
|
334
|
+
---------
|
|
335
|
+
* ``<stage_path>``: The path to the file to delete in a Stage.
|
|
336
|
+
* ``<group_id>``: The ID of the workspace group in which the
|
|
337
|
+
Stage is attached.
|
|
338
|
+
* ``<group_name>``: The name of the workspace group in which
|
|
339
|
+
the Stage is attached.
|
|
340
|
+
|
|
341
|
+
Remarks
|
|
342
|
+
-------
|
|
343
|
+
* The ``IN GROUP`` clause specifies the ID or the name of the
|
|
344
|
+
workspace group in which the Stage is attached.
|
|
345
|
+
|
|
346
|
+
Example
|
|
347
|
+
--------
|
|
348
|
+
The following command deletes a file from a Stage attached to
|
|
349
|
+
a workspace group named **wsg1**::
|
|
350
|
+
|
|
351
|
+
DROP STAGE FILE '/data/stats.csv' IN GROUP 'wsg1';
|
|
352
|
+
|
|
353
|
+
See Also
|
|
354
|
+
--------
|
|
355
|
+
* ``DROP STAGE FOLDER``
|
|
356
|
+
|
|
357
|
+
""" # noqa: E501
|
|
187
358
|
|
|
188
359
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
189
360
|
wg = get_workspace_group(params)
|
|
@@ -196,7 +367,9 @@ DropStageFileHandler.register(overwrite=True)
|
|
|
196
367
|
|
|
197
368
|
class DropStageFolderHandler(SQLHandler):
|
|
198
369
|
"""
|
|
199
|
-
DROP STAGE FOLDER stage_path
|
|
370
|
+
DROP STAGE FOLDER stage_path
|
|
371
|
+
[ in_group ]
|
|
372
|
+
[ recursive ];
|
|
200
373
|
|
|
201
374
|
# Path to stage folder
|
|
202
375
|
stage_path = '<stage-path>'
|
|
@@ -213,7 +386,38 @@ class DropStageFolderHandler(SQLHandler):
|
|
|
213
386
|
# Should folers be deleted recursively?
|
|
214
387
|
recursive = RECURSIVE
|
|
215
388
|
|
|
216
|
-
|
|
389
|
+
Description
|
|
390
|
+
-----------
|
|
391
|
+
Deletes a folder from a Stage.
|
|
392
|
+
|
|
393
|
+
Refer to `Stage <https://docs.singlestore.com/cloud/developer-resources/stage-storage-service/>`_
|
|
394
|
+
for more information.
|
|
395
|
+
|
|
396
|
+
Arguments
|
|
397
|
+
---------
|
|
398
|
+
* ``<stage_path>``: The path to the folder to delete in a Stage.
|
|
399
|
+
* ``<group_id>``: The ID of the workspace group in which the
|
|
400
|
+
Stage is attached.
|
|
401
|
+
* ``<group_name>``: The name of the workspace group in which the
|
|
402
|
+
Stage is attached.
|
|
403
|
+
|
|
404
|
+
Remarks
|
|
405
|
+
-------
|
|
406
|
+
* The ``RECURSIVE`` clause indicates that the specified folder
|
|
407
|
+
is deleted recursively.
|
|
408
|
+
|
|
409
|
+
Example
|
|
410
|
+
-------
|
|
411
|
+
The following command recursively deletes a folder from a Stage
|
|
412
|
+
attached to a workspace group named **wsg1**::
|
|
413
|
+
|
|
414
|
+
DROP STAGE FOLDER '/data/' IN GROUP 'wsg1' RECURSIVE;
|
|
415
|
+
|
|
416
|
+
See Also
|
|
417
|
+
--------
|
|
418
|
+
* ``DROP STAGE FILE``
|
|
419
|
+
|
|
420
|
+
""" # noqa: E501
|
|
217
421
|
|
|
218
422
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|
|
219
423
|
wg = get_workspace_group(params)
|
|
@@ -229,7 +433,9 @@ DropStageFolderHandler.register(overwrite=True)
|
|
|
229
433
|
|
|
230
434
|
class CreateStageFolderHandler(SQLHandler):
|
|
231
435
|
"""
|
|
232
|
-
CREATE STAGE FOLDER stage_path
|
|
436
|
+
CREATE STAGE FOLDER stage_path
|
|
437
|
+
[ in_group ]
|
|
438
|
+
[ overwrite ];
|
|
233
439
|
|
|
234
440
|
# Workspace group
|
|
235
441
|
in_group = IN GROUP { group_id | group_name }
|
|
@@ -246,6 +452,33 @@ class CreateStageFolderHandler(SQLHandler):
|
|
|
246
452
|
# Should an existing folder be overwritten?
|
|
247
453
|
overwrite = OVERWRITE
|
|
248
454
|
|
|
455
|
+
Description
|
|
456
|
+
-----------
|
|
457
|
+
Creates a new folder at the specified path in a Stage.
|
|
458
|
+
|
|
459
|
+
Arguments
|
|
460
|
+
---------
|
|
461
|
+
* ``<stage_path>``: The path in a Stage where the folder
|
|
462
|
+
is created. The path must end with a trailing slash (/).
|
|
463
|
+
* ``<group_id>``: The ID of the workspace group in which
|
|
464
|
+
the Stage is attached.
|
|
465
|
+
* ``<group_name>``: The name of the workspace group in
|
|
466
|
+
which the Stage is attached.
|
|
467
|
+
|
|
468
|
+
Remarks
|
|
469
|
+
-------
|
|
470
|
+
* If the ``OVERWRITE`` clause is specified, any existing
|
|
471
|
+
folder at the specified path is overwritten.
|
|
472
|
+
* The ``IN GROUP`` clause specifies the ID or the name of
|
|
473
|
+
the workspace group in which the Stage is attached.
|
|
474
|
+
|
|
475
|
+
Example
|
|
476
|
+
-------
|
|
477
|
+
The following command creates a folder in a Stage attached
|
|
478
|
+
to a workspace group named **wsg1**::
|
|
479
|
+
|
|
480
|
+
CREATE STAGE FOLDER `/data/csv/` IN GROUP 'wsg1';
|
|
481
|
+
|
|
249
482
|
"""
|
|
250
483
|
|
|
251
484
|
def run(self, params: Dict[str, Any]) -> Optional[FusionSQLResult]:
|