Skip to content

Commit

Permalink
PR: Test execute explain - type index node
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Mar 29, 2023
1 parent 0100262 commit b5f8ed1
Showing 1 changed file with 257 additions and 0 deletions.
257 changes: 257 additions & 0 deletions tests/integration/explain/execute/type_join_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
// Copyright 2022 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_execute

import (
"testing"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

func TestExecuteExplainRequestWithAOneToOneJoin(t *testing.T) {

test := testUtils.TestCase{

Description: "Explain a one-to-one join relation query, with alias.",

Actions: []any{
gqlSchemaExecuteExplain(),

// Authors
create2AuthorDocuments(),

// Contacts
create2AuthorContactDocuments(),

testUtils.Request{
Request: `query @explain(type: execute) {
Author {
OnlyEmail: contact {
email
}
}
}`,

Results: []dataMap{
{
"explain": dataMap{
"executionSuccess": true,
"planExecutionCount": 3,
"sizeOfResult": 2,
"selectTopNode": dataMap{
"selectNode": dataMap{
"typeIndexJoin": dataMap{
"timesTypeIndexJoinNodeExecuted": uint64(3),
"scanNode": dataMap{
"timesScanned": uint64(3),
"attemptsToFetchDocument": uint64(3),
"documentsMatched": uint64(2),
},
},
"timesDockeyDidNotMatch": uint64(0),
"timesPassedTopFilter": uint64(2),
"timesSelectNodeExecuted": uint64(3),
},
},
"actualResult": []dataMap{
{
"OnlyEmail": dataMap{
"email": "cornelia_funke@example.com",
},
},
{
"OnlyEmail": dataMap{
"email": "john_grisham@example.com",
},
},
},
},
},
},
},
},
}

executeTestCase(t, test)
}

func TestExecuteExplainWithMultipleOneToOneJoins(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (execute) with two one-to-one join relation.",

Actions: []any{
gqlSchemaExecuteExplain(),

// Authors
create2AuthorDocuments(),

// Contacts
create2AuthorContactDocuments(),

testUtils.Request{
Request: `query @explain(type: execute) {
Author {
OnlyEmail: contact {
email
}
contact {
cell
email
}
}
}`,

Results: []dataMap{
{
"explain": dataMap{
"executionSuccess": true,
"planExecutionCount": 3,
"sizeOfResult": 2,
"selectTopNode": dataMap{
"selectNode": dataMap{
"parallelNode": []dataMap{
{
"typeIndexJoin": dataMap{
"timesTypeIndexJoinNodeExecuted": uint64(3),
"scanNode": dataMap{
"timesScanned": uint64(3),
"attemptsToFetchDocument": uint64(3),
"documentsMatched": uint64(2),
},
},
},
{
"typeIndexJoin": dataMap{
"timesTypeIndexJoinNodeExecuted": uint64(3),
"scanNode": dataMap{
"timesScanned": uint64(3),
"attemptsToFetchDocument": uint64(3),
"documentsMatched": uint64(2),
},
},
},
},
"timesDockeyDidNotMatch": uint64(0),
"timesPassedTopFilter": uint64(2),
"timesSelectNodeExecuted": uint64(3),
},
},
"actualResult": []dataMap{
{
"OnlyEmail": dataMap{
"email": "cornelia_funke@example.com",
},
"contact": dataMap{
"email": "cornelia_funke@example.com",
"cell": "5197212302",
},
},
{
"OnlyEmail": dataMap{
"email": "john_grisham@example.com",
},
"contact": dataMap{
"email": "john_grisham@example.com",
"cell": "5197212301",
},
},
},
},
},
},
},
},
}

executeTestCase(t, test)
}

func TestExecuteExplainWithTwoLevelDeepNestedJoins(t *testing.T) {
test := testUtils.TestCase{

Description: "Explain (execute) with two nested level deep one to one join.",

Actions: []any{
gqlSchemaExecuteExplain(),

// Authors
create2AuthorDocuments(),

// Contacts
create2AuthorContactDocuments(),

// Addresses
create2AddressDocuments(),

testUtils.Request{
Request: `query @explain(type: execute) {
Author {
name
contact {
email
address {
city
}
}
}
}`,

Results: []dataMap{
{
"explain": dataMap{
"executionSuccess": true,
"planExecutionCount": 3,
"sizeOfResult": 2,
"selectTopNode": dataMap{
"selectNode": dataMap{
"typeIndexJoin": dataMap{
"timesTypeIndexJoinNodeExecuted": uint64(3),
"scanNode": dataMap{
"timesScanned": uint64(3),
"attemptsToFetchDocument": uint64(3),
"documentsMatched": uint64(2),
},
},
"timesDockeyDidNotMatch": uint64(0),
"timesPassedTopFilter": uint64(2),
"timesSelectNodeExecuted": uint64(3),
},
},
"actualResult": []dataMap{
{
"name": "Cornelia Funke",
"contact": dataMap{
"email": "cornelia_funke@example.com",
"address": dataMap{
"city": "Brampton",
},
},
},
{
"name": "John Grisham",
"contact": dataMap{
"email": "john_grisham@example.com",
"address": dataMap{
"city": "Waterloo",
},
},
},
},
},
},
},
},
},
}

executeTestCase(t, test)
}

0 comments on commit b5f8ed1

Please sign in to comment.