Skip to content

Commit

Permalink
Query plan for EXPLAIN and handover (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxAake authored Jan 30, 2025
1 parent ec4d186 commit 4935ecd
Show file tree
Hide file tree
Showing 5 changed files with 2,827 additions and 2,230 deletions.
20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neo4j-labs/experimental-query-api-wrapper",
"version": "0.0.1-alpha06",
"version": "0.0.1-alpha07",
"description": "Experimental wrapper library to access Neo4j Database using Query API with a neo4j-driver-like interface.",
"main": "lib/index.js",
"types": "types/index.d.ts",
Expand All @@ -18,19 +18,27 @@
},
"repository": {
"type": "git",
"url": "git://github.com/neo4j/neo4j-javascript-driver.git"
"url": "git://github.com/neo4j-drivers/experimental-query-api-wrapper.git"
},
"keywords": [
"http",
"neo4j",
"driver"
],
"author": "Antonio Barcélos",
"author": "Neo4j",
"contributors": [
{
"name": "Max Gustafsson"
},
{
"name": "Antonio Barcélos"
}
],
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/neo4j/neo4j-javascript-driver/issues"
"url": "https://github.com/neo4j-drivers/experimental-query-api-wrapper/issues"
},
"homepage": "https://github.com/neo4j/neo4j-javascript-driver#readme",
"homepage": "https://github.com/neo4j-drivers/experimental-query-api-wrapper#readme",
"devDependencies": {
"@types/jest": "^29.5.3",
"downdoc": "^1.0.2-stable",
Expand All @@ -42,7 +50,7 @@
"typescript": "^4.9.5"
},
"dependencies": {
"neo4j-driver-core": "^5.26.0"
"neo4j-driver-core": "^5.27.0"
},
"engines": {
"node": ">=18.0.0"
Expand Down
3 changes: 3 additions & 0 deletions src/http-connection/query.codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export type RawQuerySuccessResponse = {
counters: Counters
bookmarks: string[]
profiledQueryPlan?: ProfiledQueryPlan
queryPlan?: ProfiledQueryPlan
notifications?: NotificationShape[]
[str: string]: unknown
}
Expand Down Expand Up @@ -202,6 +203,8 @@ class QuerySuccessResponseCodec extends QueryResponseCodec {
stats: this._decodeStats(this._response.counters),
profile: this._response.profiledQueryPlan != null ?
this._decodeProfile(this._response.profiledQueryPlan) : null,
plan: this._response.queryPlan != null ?
this._decodeProfile(this._response.queryPlan) : null,
notifications: this._response.notifications
}
}
Expand Down
30 changes: 29 additions & 1 deletion test/integration/minimum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ when(config.version >= 5.23, () => describe.each(runners())('minimum requirement
const { summary} = await runner(session, 'PROFILE RETURN 1')

expect(summary.plan).not.toBe(false)

const plan: Plan = summary.plan as Plan
expect(plan.identifiers).toEqual(['`1`'])
expect(plan.operatorType).toEqual('ProduceResults@neo4j')
Expand Down Expand Up @@ -352,6 +352,34 @@ when(config.version >= 5.23, () => describe.each(runners())('minimum requirement
}
})

it('should be able to return ResultSummary.plan when EXPLAIN', async () => {
for await (const session of withSession({ database: config.database })) {
const { summary} = await runner(session, 'EXPLAIN RETURN 1')

expect(summary.plan).not.toBe(false)

const plan: Plan = summary.plan as Plan
expect(plan.identifiers).toEqual(['`1`'])
expect(plan.operatorType).toEqual('ProduceResults@neo4j')

expect(plan.children.length).toBe(1)

const [child] = plan.children
expect(child.identifiers).toEqual(['`1`'])
expect(child.operatorType).toEqual('Projection@neo4j')

expect(child.children.length).toBe(0)
}
})

it('should not return ResultSummary.profile when EXPLAIN',async () => {
for await (const session of withSession({ database: config.database })) {
const { summary} = await runner(session, 'EXPLAIN RETURN 1')

expect(summary.profile).toBe(false)
}
})

it('should be able to receive bookmarks', async () => {
for await (const session of withSession({ database: config.database })) {
expect(session.lastBookmarks()).toEqual([])
Expand Down
Loading

0 comments on commit 4935ecd

Please sign in to comment.