Skip to content

Commit 8820a00

Browse files
Various fixes in the ES|QL query builder docstrings
1 parent 3d47b77 commit 8820a00

File tree

1 file changed

+44
-32
lines changed

1 file changed

+44
-32
lines changed

elasticsearch/esql/esql.py

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ def eval(self, *columns: ExpressionType, **named_columns: ExpressionType) -> "Ev
284284

285285
def fork(
286286
self,
287-
fork1: "ESQLBase",
288-
fork2: Optional["ESQLBase"] = None,
289-
fork3: Optional["ESQLBase"] = None,
290-
fork4: Optional["ESQLBase"] = None,
291-
fork5: Optional["ESQLBase"] = None,
292-
fork6: Optional["ESQLBase"] = None,
293-
fork7: Optional["ESQLBase"] = None,
294-
fork8: Optional["ESQLBase"] = None,
287+
fork1: "Branch",
288+
fork2: Optional["Branch"] = None,
289+
fork3: Optional["Branch"] = None,
290+
fork4: Optional["Branch"] = None,
291+
fork5: Optional["Branch"] = None,
292+
fork6: Optional["Branch"] = None,
293+
fork7: Optional["Branch"] = None,
294+
fork8: Optional["Branch"] = None,
295295
) -> "Fork":
296296
"""The ``FORK`` processing command creates multiple execution branches to operate on the
297297
same input data and combines the results in a single output table.
@@ -377,7 +377,7 @@ def limit(self, max_number_of_rows: int) -> "Limit":
377377
return Limit(self, max_number_of_rows)
378378

379379
def lookup_join(self, lookup_index: IndexType) -> "LookupJoin":
380-
"""`LOOKUP JOIN` enables you to add data from another index, AKA a 'lookup' index,
380+
"""``LOOKUP JOIN`` enables you to add data from another index, AKA a 'lookup' index,
381381
to your ES|QL query results, simplifying data enrichment and analysis workflows.
382382
383383
:param lookup_index: The name of the lookup index. This must be a specific index
@@ -411,7 +411,7 @@ def lookup_join(self, lookup_index: IndexType) -> "LookupJoin":
411411
return LookupJoin(self, lookup_index)
412412

413413
def mv_expand(self, column: FieldType) -> "MvExpand":
414-
"""The `MV_EXPAND` processing command expands multivalued columns into one row per
414+
"""The ``MV_EXPAND`` processing command expands multivalued columns into one row per
415415
value, duplicating other columns.
416416
417417
:param column: The multivalued column to expand.
@@ -449,7 +449,7 @@ def rerank(self, *query: ExpressionType, **named_query: ExpressionType) -> "Rera
449449
:param named_query: The query text used to rerank the documents, given as a
450450
keyword argument. The argument name is used for the column
451451
name. If the query is given as a positional argument, the
452-
results will be stored in a column named `_score`. If the
452+
results will be stored in a column named ``_score``. If the
453453
specified column already exists, it will be overwritten with
454454
the new results.
455455
@@ -540,7 +540,7 @@ def stats(
540540
:param named_expressions: A list of expressions, given as keyword arguments. The
541541
argument names are used for the returned aggregated values.
542542
543-
Note that only one of `expressions` and `named_expressions` must be provided.
543+
Note that only one of ``expressions`` and ``named_expressions`` must be provided.
544544
545545
Examples::
546546
@@ -596,7 +596,7 @@ def stats(
596596

597597
def where(self, *expressions: ExpressionType) -> "Where":
598598
"""The ``WHERE`` processing command produces a table that contains all the rows
599-
from the input table for which the provided condition evaluates to `true`.
599+
from the input table for which the provided condition evaluates to ``true``.
600600
601601
:param expressions: A list of boolean expressions, given as positional arguments.
602602
These expressions are combined with an ``AND`` logical operator.
@@ -720,21 +720,22 @@ def __init__(self, parent: ESQLBase, value: FieldType):
720720
self._pvalue_name: Optional[str] = None
721721

722722
def on(self, key: FieldType) -> "ChangePoint":
723-
"""Continuation of the `CHANGE_POINT` command.
723+
"""Continuation of the ``CHANGE_POINT`` command.
724724
725725
:param key: The column with the key to order the values by. If not specified,
726-
`@timestamp` is used.
726+
``@timestamp`` is used.
727727
"""
728728
self._key = key
729729
return self
730730

731731
def as_(self, type_name: str, pvalue_name: str) -> "ChangePoint":
732-
"""Continuation of the `CHANGE_POINT` command.
732+
"""Continuation of the ``CHANGE_POINT`` command.
733733
734734
:param type_name: The name of the output column with the change point type.
735-
If not specified, `type` is used.
735+
If not specified, ``type`` is used.
736736
:param pvalue_name: The name of the output column with the p-value that indicates
737-
how extreme the change point is. If not specified, `pvalue` is used.
737+
how extreme the change point is. If not specified, ``pvalue``
738+
is used.
738739
"""
739740
self._type_name = type_name
740741
self._pvalue_name = pvalue_name
@@ -771,10 +772,10 @@ def __init__(
771772
self._inference_id: Optional[str] = None
772773

773774
def with_(self, inference_id: str) -> "Completion":
774-
"""Continuation of the `COMPLETION` command.
775+
"""Continuation of the ``COMPLETION`` command.
775776
776777
:param inference_id: The ID of the inference endpoint to use for the task. The
777-
inference endpoint must be configured with the completion
778+
inference endpoint must be configured with the ``completion``
778779
task type.
779780
"""
780781
self._inference_id = inference_id
@@ -863,7 +864,7 @@ def on(self, match_field: FieldType) -> "Enrich":
863864
:param match_field: The match field. ``ENRICH`` uses its value to look for records
864865
in the enrich index. If not specified, the match will be
865866
performed on the column with the same name as the
866-
`match_field` defined in the enrich policy.
867+
``match_field`` defined in the enrich policy.
867868
"""
868869
self._match_field = match_field
869870
return self
@@ -953,14 +954,14 @@ class Fork(ESQLBase):
953954
def __init__(
954955
self,
955956
parent: ESQLBase,
956-
fork1: ESQLBase,
957-
fork2: Optional[ESQLBase] = None,
958-
fork3: Optional[ESQLBase] = None,
959-
fork4: Optional[ESQLBase] = None,
960-
fork5: Optional[ESQLBase] = None,
961-
fork6: Optional[ESQLBase] = None,
962-
fork7: Optional[ESQLBase] = None,
963-
fork8: Optional[ESQLBase] = None,
957+
fork1: "Branch",
958+
fork2: Optional["Branch"] = None,
959+
fork3: Optional["Branch"] = None,
960+
fork4: Optional["Branch"] = None,
961+
fork5: Optional["Branch"] = None,
962+
fork6: Optional["Branch"] = None,
963+
fork7: Optional["Branch"] = None,
964+
fork8: Optional["Branch"] = None,
964965
):
965966
super().__init__(parent)
966967
self._branches = [fork1, fork2, fork3, fork4, fork5, fork6, fork7, fork8]
@@ -1040,7 +1041,7 @@ def __init__(self, parent: ESQLBase, lookup_index: IndexType):
10401041
self._field: Optional[FieldType] = None
10411042

10421043
def on(self, field: FieldType) -> "LookupJoin":
1043-
"""Continuation of the `LOOKUP_JOIN` command.
1044+
"""Continuation of the ``LOOKUP JOIN`` command.
10441045
10451046
:param field: The field to join on. This field must exist in both your current query
10461047
results and in the lookup index. If the field contains multi-valued
@@ -1117,14 +1118,19 @@ def __init__(
11171118
self._inference_id: Optional[str] = None
11181119

11191120
def on(self, *fields: str) -> "Rerank":
1121+
"""Continuation of the ``RERANK`` command.
1122+
1123+
:param fields: One or more fields to use for reranking. These fields should
1124+
contain the text that the reranking model will evaluate.
1125+
"""
11201126
self._fields = fields
11211127
return self
11221128

11231129
def with_(self, inference_id: str) -> "Rerank":
1124-
"""Continuation of the `COMPLETION` command.
1130+
"""Continuation of the ``RERANK`` command.
11251131
11261132
:param inference_id: The ID of the inference endpoint to use for the task. The
1127-
inference endpoint must be configured with the completion
1133+
inference endpoint must be configured with the ``rerank``
11281134
task type.
11291135
"""
11301136
self._inference_id = inference_id
@@ -1210,6 +1216,12 @@ def __init__(
12101216
self._grouping_expressions: Optional[Tuple[ExpressionType, ...]] = None
12111217

12121218
def by(self, *grouping_expressions: ExpressionType) -> "Stats":
1219+
"""Continuation of the ``STATS`` command.
1220+
1221+
:param grouping_expressions: Expressions that output the values to group by.
1222+
If their names coincide with one of the computed
1223+
columns, that column will be ignored.
1224+
"""
12131225
self._grouping_expressions = grouping_expressions
12141226
return self
12151227

0 commit comments

Comments
 (0)