Skip to content

Commit

Permalink
Remove esql version (#1849)
Browse files Browse the repository at this point in the history
ES|QL in 8.14 will not require a `version` parameter in requests to `_query`, after all.
This removes the `version` parameter from the ES|QL runner, essentially reverting #1841.
  • Loading branch information
alex-spies authored May 29, 2024
1 parent 31a0eb7 commit fc8822e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 17 deletions.
2 changes: 0 additions & 2 deletions docs/track.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,6 @@ Properties
""""""""""

* ``query`` (mandatory): An ES|QL query which starts with a source command followed by processing commands.
* ``version`` (optional): The version of the ES|QL query language. Defaults to the first released version, ``2024.04.01``. See the docs for `available versions <https://www.elastic.co/guide/en/elasticsearch/reference/master/esql-version.html>`_.
* ``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.

Expand All @@ -3154,7 +3153,6 @@ Example::
"name": "default",
"operation-type": "esql",
"query": "FROM logs-* | STATS count=count(*) BY agent.hostname | SORT count DESC | LIMIT 20",
"version": "2024.04.01",
"filter": {
"range": {
"timestamp": {
Expand Down
1 change: 0 additions & 1 deletion esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2892,7 +2892,6 @@ async def __call__(self, es, params):
query = mandatory(params, "query", self)
body = params.get("body", {})
body["query"] = query
body["version"] = params.get("version", "2024.04.01")
query_filter = params.get("filter")
if query_filter:
body["filter"] = query_filter
Expand Down
17 changes: 3 additions & 14 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7686,7 +7686,7 @@ async def test_esql_without_query_filter(self, es):
esql = runner.Esql()
result = await esql(es, params={"query": "from logs-* | stats c = count(*)"})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from logs-* | stats c = count(*)", "version": "2024.04.01"}
expected_body = {"query": "from logs-* | stats c = count(*)"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
Expand All @@ -7698,7 +7698,7 @@ async def test_esql_with_query_filter(self, es):
query_filter = {"range": {"@timestamp": {"gte": "2023"}}}
result = await esql(es, params={"query": "from * | limit 1", "filter": query_filter})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from * | limit 1", "version": "2024.04.01", "filter": query_filter}
expected_body = {"query": "from * | limit 1", "filter": query_filter}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
Expand All @@ -7711,16 +7711,5 @@ async def test_esql_with_body(self, es):
result = await esql(es, params={"query": "from * | limit 1", "body": {"pragma": pragma}})
assert result == {"weight": 1, "unit": "ops", "success": True}

expected_body = {"pragma": pragma, "query": "from * | limit 1", "version": "2024.04.01"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
@pytest.mark.asyncio
async def test_esql_with_version(self, es):
es.options.return_value = es
es.perform_request = mock.AsyncMock()
esql = runner.Esql()
result = await esql(es, params={"query": "from * | limit 1", "version": "wow"})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from * | limit 1", "version": "wow"}
expected_body = {"pragma": pragma, "query": "from * | limit 1"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

0 comments on commit fc8822e

Please sign in to comment.