@@ -31,6 +31,8 @@ class EsqlClient(NamespacedClient):
31
31
"columnar" ,
32
32
"filter" ,
33
33
"include_ccs_metadata" ,
34
+ "keep_alive" ,
35
+ "keep_on_completion" ,
34
36
"locale" ,
35
37
"params" ,
36
38
"profile" ,
@@ -88,7 +90,9 @@ async def async_query(
88
90
parameter, runs it, and returns the results.
89
91
:param allow_partial_results: If `true`, partial results will be returned if
90
92
there are shard failures, but the query can continue to execute on other
91
- clusters and shards.
93
+ clusters and shards. If `false`, the query will fail if there are any failures.
94
+ To override the default behavior, you can set the `esql.query.allow_partial_results`
95
+ cluster setting to `false`.
92
96
:param columnar: By default, ES|QL returns results as rows. For example, FROM
93
97
returns each individual document as one row. For the JSON, YAML, CBOR and
94
98
smile formats, ES|QL can return the results in a columnar fashion where one
@@ -151,10 +155,6 @@ async def async_query(
151
155
__query ["format" ] = format
152
156
if human is not None :
153
157
__query ["human" ] = human
154
- if keep_alive is not None :
155
- __query ["keep_alive" ] = keep_alive
156
- if keep_on_completion is not None :
157
- __query ["keep_on_completion" ] = keep_on_completion
158
158
if pretty is not None :
159
159
__query ["pretty" ] = pretty
160
160
if not __body :
@@ -166,6 +166,10 @@ async def async_query(
166
166
__body ["filter" ] = filter
167
167
if include_ccs_metadata is not None :
168
168
__body ["include_ccs_metadata" ] = include_ccs_metadata
169
+ if keep_alive is not None :
170
+ __body ["keep_alive" ] = keep_alive
171
+ if keep_on_completion is not None :
172
+ __body ["keep_on_completion" ] = keep_on_completion
169
173
if locale is not None :
170
174
__body ["locale" ] = locale
171
175
if params is not None :
@@ -248,6 +252,14 @@ async def async_query_get(
248
252
drop_null_columns : t .Optional [bool ] = None ,
249
253
error_trace : t .Optional [bool ] = None ,
250
254
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
255
+ format : t .Optional [
256
+ t .Union [
257
+ str ,
258
+ t .Literal [
259
+ "arrow" , "cbor" , "csv" , "json" , "smile" , "tsv" , "txt" , "yaml"
260
+ ],
261
+ ]
262
+ ] = None ,
251
263
human : t .Optional [bool ] = None ,
252
264
keep_alive : t .Optional [t .Union [str , t .Literal [- 1 ], t .Literal [0 ]]] = None ,
253
265
pretty : t .Optional [bool ] = None ,
@@ -273,6 +285,7 @@ async def async_query_get(
273
285
will be removed from the `columns` and `values` portion of the results. If
274
286
`true`, the response will include an extra section under the name `all_columns`
275
287
which has the name of all the columns.
288
+ :param format: A short version of the Accept header, for example `json` or `yaml`.
276
289
:param keep_alive: The period for which the query and its results are stored
277
290
in the cluster. When this period expires, the query and its results are deleted,
278
291
even if the query is still ongoing.
@@ -293,6 +306,8 @@ async def async_query_get(
293
306
__query ["error_trace" ] = error_trace
294
307
if filter_path is not None :
295
308
__query ["filter_path" ] = filter_path
309
+ if format is not None :
310
+ __query ["format" ] = format
296
311
if human is not None :
297
312
__query ["human" ] = human
298
313
if keep_alive is not None :
@@ -366,6 +381,87 @@ async def async_query_stop(
366
381
path_parts = __path_parts ,
367
382
)
368
383
384
+ @_rewrite_parameters ()
385
+ @_stability_warning (Stability .EXPERIMENTAL )
386
+ async def get_query (
387
+ self ,
388
+ * ,
389
+ id : str ,
390
+ error_trace : t .Optional [bool ] = None ,
391
+ filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
392
+ human : t .Optional [bool ] = None ,
393
+ pretty : t .Optional [bool ] = None ,
394
+ ) -> ObjectApiResponse [t .Any ]:
395
+ """
396
+ .. raw:: html
397
+
398
+ <p>Get a specific running ES|QL query information.
399
+ Returns an object extended information about a running ES|QL query.</p>
400
+
401
+
402
+ :param id: The query ID
403
+ """
404
+ if id in SKIP_IN_PATH :
405
+ raise ValueError ("Empty value passed for parameter 'id'" )
406
+ __path_parts : t .Dict [str , str ] = {"id" : _quote (id )}
407
+ __path = f'/_query/queries/{ __path_parts ["id" ]} '
408
+ __query : t .Dict [str , t .Any ] = {}
409
+ if error_trace is not None :
410
+ __query ["error_trace" ] = error_trace
411
+ if filter_path is not None :
412
+ __query ["filter_path" ] = filter_path
413
+ if human is not None :
414
+ __query ["human" ] = human
415
+ if pretty is not None :
416
+ __query ["pretty" ] = pretty
417
+ __headers = {"accept" : "application/json" }
418
+ return await self .perform_request ( # type: ignore[return-value]
419
+ "GET" ,
420
+ __path ,
421
+ params = __query ,
422
+ headers = __headers ,
423
+ endpoint_id = "esql.get_query" ,
424
+ path_parts = __path_parts ,
425
+ )
426
+
427
+ @_rewrite_parameters ()
428
+ @_stability_warning (Stability .EXPERIMENTAL )
429
+ async def list_queries (
430
+ self ,
431
+ * ,
432
+ error_trace : t .Optional [bool ] = None ,
433
+ filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
434
+ human : t .Optional [bool ] = None ,
435
+ pretty : t .Optional [bool ] = None ,
436
+ ) -> ObjectApiResponse [t .Any ]:
437
+ """
438
+ .. raw:: html
439
+
440
+ <p>Get running ES|QL queries information.
441
+ Returns an object containing IDs and other information about the running ES|QL queries.</p>
442
+
443
+ """
444
+ __path_parts : t .Dict [str , str ] = {}
445
+ __path = "/_query/queries"
446
+ __query : t .Dict [str , t .Any ] = {}
447
+ if error_trace is not None :
448
+ __query ["error_trace" ] = error_trace
449
+ if filter_path is not None :
450
+ __query ["filter_path" ] = filter_path
451
+ if human is not None :
452
+ __query ["human" ] = human
453
+ if pretty is not None :
454
+ __query ["pretty" ] = pretty
455
+ __headers = {"accept" : "application/json" }
456
+ return await self .perform_request ( # type: ignore[return-value]
457
+ "GET" ,
458
+ __path ,
459
+ params = __query ,
460
+ headers = __headers ,
461
+ endpoint_id = "esql.list_queries" ,
462
+ path_parts = __path_parts ,
463
+ )
464
+
369
465
@_rewrite_parameters (
370
466
body_fields = (
371
467
"query" ,
@@ -422,7 +518,9 @@ async def query(
422
518
parameter, runs it, and returns the results.
423
519
:param allow_partial_results: If `true`, partial results will be returned if
424
520
there are shard failures, but the query can continue to execute on other
425
- clusters and shards.
521
+ clusters and shards. If `false`, the query will fail if there are any failures.
522
+ To override the default behavior, you can set the `esql.query.allow_partial_results`
523
+ cluster setting to `false`.
426
524
:param columnar: By default, ES|QL returns results as rows. For example, FROM
427
525
returns each individual document as one row. For the JSON, YAML, CBOR and
428
526
smile formats, ES|QL can return the results in a columnar fashion where one
0 commit comments