forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to explain-debug all nodes (sourcenetwork#1563)
Resolves sourcenetwork#948 ## Description Implements a new type of explain called `debug` which dumps all plan nodes (even non-explainable nodes) as a graph (has no attributes). Usage is similar to other explain types, but would just do `@explain(type: debug)` instead of `@explain(type: simple)` or `@explain(type: execute)`. Example Request: ``` query @Explain(type: debug) { Author (groupBy: [age]) { age _group { name } } } ``` Response: ``` { "data": [ "explain": { "selectTopNode": { "groupNode": { "selectNode": { "pipeNode": { "scanNode": {} } } } } } ] } ```
- Loading branch information
1 parent
7b7f2f9
commit b830614
Showing
44 changed files
with
4,055 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2023 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package test_explain_debug | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
explainUtils "github.com/sourcenetwork/defradb/tests/integration/explain" | ||
) | ||
|
||
func TestDebugExplainRequest(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Description: "Explain (debug) a basic request, assert full graph.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
Request: `query @explain(type: debug) { | ||
Author { | ||
name | ||
age | ||
} | ||
}`, | ||
|
||
ExpectedFullGraph: []dataMap{basicPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2023 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package test_explain_debug | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
explainUtils "github.com/sourcenetwork/defradb/tests/integration/explain" | ||
) | ||
|
||
var createPattern = dataMap{ | ||
"explain": dataMap{ | ||
"createNode": dataMap{ | ||
"selectTopNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"scanNode": dataMap{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestDebugExplainMutationRequestWithCreate(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Description: "Explain (debug) mutation request with create.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `mutation @explain(type: debug) { | ||
create_Author(data: "{\"name\": \"Shahzad Lone\",\"age\": 27,\"verified\": true}") { | ||
name | ||
age | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{createPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainMutationRequestDoesNotCreateDocGivenDuplicate(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
Description: "Explain (debug) mutation request with create, document exists.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `mutation @explain(type: debug) { | ||
create_Author(data: "{\"name\": \"Shahzad Lone\",\"age\": 27}") { | ||
name | ||
age | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{createPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |
Oops, something went wrong.