Skip to content

Commit 9d8d4c0

Browse files
committed
Added peak_memory_usage as a property of AQL queries.
1 parent aecc467 commit 9d8d4c0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

arango/formatter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ def format_aql_query(body: Json) -> Json:
322322
result["stream"] = body["stream"]
323323
if "user" in body:
324324
result["user"] = body["user"]
325+
326+
# New in 3.11
327+
if "peakMemoryUsage" in body:
328+
result["peak_memory_usage"] = body["peakMemoryUsage"]
325329
return verify_format(body, result)
326330

327331

tests/test_aql.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from packaging import version
2+
13
from arango.exceptions import (
24
AQLCacheClearError,
35
AQLCacheConfigureError,
@@ -26,7 +28,7 @@ def test_aql_attributes(db, username):
2628
assert repr(db.aql.cache) == f"<AQLQueryCache in {db.name}>"
2729

2830

29-
def test_aql_query_management(db, bad_db, col, docs):
31+
def test_aql_query_management(db_version, db, bad_db, col, docs):
3032
plan_fields = [
3133
"estimatedNrItems",
3234
"estimatedCost",
@@ -162,7 +164,7 @@ def test_aql_query_management(db, bad_db, col, docs):
162164
assert new_tracking["track_bind_vars"] is True
163165
assert new_tracking["track_slow_queries"] is True
164166

165-
# Kick off some long lasting queries in the background
167+
# Kick off some long-lasting queries in the background
166168
db.begin_async_execution().aql.execute("RETURN SLEEP(100)")
167169
db.begin_async_execution().aql.execute("RETURN SLEEP(50)")
168170

@@ -175,6 +177,8 @@ def test_aql_query_management(db, bad_db, col, docs):
175177
assert "state" in query
176178
assert "bind_vars" in query
177179
assert "runtime" in query
180+
if db_version >= version.parse("3.11"):
181+
assert "peak_memory_usage" in query
178182
assert len(queries) == 2
179183

180184
# Test list queries with bad database

0 commit comments

Comments
 (0)