-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8cb30b5
commit 1e186cc
Showing
10 changed files
with
894 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// 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 groupPattern = dataMap{ | ||
"explain": dataMap{ | ||
"selectTopNode": dataMap{ | ||
"groupNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"pipeNode": dataMap{ | ||
"scanNode": dataMap{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestDebugExplainRequestWithGroupByOnParent(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with group-by on parent.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [age]) { | ||
age | ||
_group { | ||
name | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedFullGraph: []dataMap{groupPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainRequestWithGroupByTwoFieldsOnParent(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with group-by two fields on parent.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [age, name]) { | ||
age | ||
_group { | ||
name | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedFullGraph: []dataMap{groupPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |
157 changes: 157 additions & 0 deletions
157
tests/integration/explain/debug/group_with_average_test.go
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,157 @@ | ||
// 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 debugGroupAveragePattern = dataMap{ | ||
"explain": dataMap{ | ||
"selectTopNode": dataMap{ | ||
"averageNode": dataMap{ | ||
"countNode": dataMap{ | ||
"sumNode": dataMap{ | ||
"groupNode": dataMap{ | ||
"selectNode": dataMap{ | ||
"pipeNode": dataMap{ | ||
"scanNode": dataMap{}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
func TestDebugExplainRequestWithGroupByWithAverageOnAnInnerField(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with group-by with average on inner field.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [name]) { | ||
name | ||
_avg(_group: {field: age}) | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{debugGroupAveragePattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainRequestWithAverageInsideTheInnerGroupOnAField(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with group-by with average of the inner _group on a field.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [name]) { | ||
name | ||
_avg(_group: {field: _avg}) | ||
_group(groupBy: [verified]) { | ||
verified | ||
_avg(_group: {field: age}) | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{debugGroupAveragePattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainRequestWithAverageInsideTheInnerGroupOnAFieldAndNestedGroupBy(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with group-by with average of the inner _group on a field and nested group-by.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [name]) { | ||
name | ||
_avg(_group: {field: _avg}) | ||
_group(groupBy: [verified]) { | ||
verified | ||
_avg(_group: {field: age}) | ||
_group (groupBy: [age]){ | ||
age | ||
} | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{debugGroupAveragePattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainRequestWithAverageInsideTheInnerGroupAndNestedGroupByWithAverage(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with average inside the inner _group and nested groupBy with average.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author (groupBy: [name]) { | ||
name | ||
_avg(_group: {field: _avg}) | ||
_group(groupBy: [verified]) { | ||
verified | ||
_avg(_group: {field: age}) | ||
_group (groupBy: [age]){ | ||
age | ||
_avg(_group: {field: age}) | ||
} | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{debugGroupAveragePattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/integration/explain/debug/group_with_dockey_child_test.go
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,47 @@ | ||
// 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 TestDebugExplainRequestWithDockeysOnInnerGroupSelection(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with dockeys on inner _group.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author( | ||
groupBy: [age] | ||
) { | ||
age | ||
_group(dockeys: ["bae-6a4c5bc5-b044-5a03-a868-8260af6f2254"]) { | ||
name | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{groupPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
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,82 @@ | ||
// 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 TestDebugExplainRequestWithDockeyOnParentGroupBy(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with a dockey on parent groupBy.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author( | ||
groupBy: [age], | ||
dockey: "bae-6a4c5bc5-b044-5a03-a868-8260af6f2254" | ||
) { | ||
age | ||
_group { | ||
name | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{groupPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} | ||
|
||
func TestDebugExplainRequestWithDockeysAndFilterOnParentGroupBy(t *testing.T) { | ||
test := testUtils.TestCase{ | ||
|
||
Description: "Explain (debug) request with dockeys and filter on parent groupBy.", | ||
|
||
Actions: []any{ | ||
explainUtils.SchemaForExplainTests, | ||
|
||
testUtils.ExplainRequest{ | ||
|
||
Request: `query @explain(type: debug) { | ||
Author( | ||
groupBy: [age], | ||
filter: {age: {_eq: 20}}, | ||
dockeys: [ | ||
"bae-6a4c5bc5-b044-5a03-a868-8260af6f2254", | ||
"bae-4ea9d148-13f3-5a48-a0ef-9ffd344caeed" | ||
] | ||
) { | ||
age | ||
_group { | ||
name | ||
} | ||
} | ||
}`, | ||
|
||
ExpectedPatterns: []dataMap{groupPattern}, | ||
}, | ||
}, | ||
} | ||
|
||
explainUtils.ExecuteTestCase(t, test) | ||
} |
Oops, something went wrong.