Skip to content

Add ESQL operator#1791

Merged
dnhatn merged 5 commits intoelastic:masterfrom
dnhatn:esql-operator
Oct 18, 2023
Merged

Add ESQL operator#1791
dnhatn merged 5 commits intoelastic:masterfrom
dnhatn:esql-operator

Conversation

@dnhatn
Copy link
Copy Markdown
Member

@dnhatn dnhatn commented Oct 15, 2023

This pull request introduces the ES|QL operator. This operator, for now, supports only two main parameters: query and filter.

@dnhatn dnhatn marked this pull request as ready for review October 16, 2023 00:34
@dnhatn dnhatn requested review from b-deam and gbanasiak October 16, 2023 04:16
@dnhatn
Copy link
Copy Markdown
Member Author

dnhatn commented Oct 16, 2023

/cc @craigtaverner

@dnhatn dnhatn requested a review from b-deam October 16, 2023 05:19


class Esql(Runner):
async def __call__(self, es, params):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of high level properties that operations should expose, namely:

  • request-timeout
  • headers
  • opaque-id

You can add support for these by using the Runner._transport_request_params helper method:

def _transport_request_params(params):
"""
Takes all of a runner's params and splits out request parameters, transport
level parameters, and headers into their own respective dicts.
:param params: A hash with all the respective runner's parameters.
:return: A tuple of the specific runner's params, request level parameters, transport level parameters, and headers, respectively.
"""
transport_params = {}
request_params = params.get("request-params", {})
if request_timeout := params.pop("request-timeout", None):
transport_params["request_timeout"] = request_timeout
if (ignore_status := request_params.pop("ignore", None)) or (ignore_status := params.pop("ignore", None)):
transport_params["ignore_status"] = ignore_status
headers = params.pop("headers", None) or {}
if opaque_id := params.pop("opaque-id", None):
headers.update({"x-opaque-id": opaque_id})
return params, request_params, transport_params, headers

An example of usage:

params, request_params, transport_params, headers = self._transport_request_params(params)

Copy link
Copy Markdown
Member

@b-deam b-deam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I left one comment about using a helper method around configuring the different request, transport, and header parameters but no need for another review.

@dnhatn
Copy link
Copy Markdown
Member Author

dnhatn commented Oct 18, 2023

@b-deam @gbanasiak Thanks for reviews.

@dnhatn dnhatn enabled auto-merge (squash) October 18, 2023 03:40
@dnhatn dnhatn disabled auto-merge October 18, 2023 03:40
@dnhatn dnhatn enabled auto-merge (squash) October 18, 2023 03:41
@dnhatn
Copy link
Copy Markdown
Member Author

dnhatn commented Oct 18, 2023

@elasticmachine run rally/it-python310 please


* ``query`` (mandatory): An ES|QL query starts with a source command followed processing commands.
* ``filter`` (optional): A query filter defined in `Elasticsearch query DSL <https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html>`_.
* ``body`` (optional): The query body.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description here should indicate that this is used for anything additions to put into the body, since the query will already be placed there. For example, we use this for pragma.

@gbanasiak gbanasiak added this to the 2.10.0 milestone Oct 18, 2023
@dnhatn dnhatn deleted the esql-operator branch October 18, 2023 14:26
@gbanasiak gbanasiak added the enhancement Improves the status quo label Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improves the status quo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants