Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add typeIndexJoin explainable attributes. #499

Merged
merged 2 commits into from
Jun 10, 2022

Conversation

shahzadlone
Copy link
Member

@shahzadlone shahzadlone commented Jun 3, 2022

RELEVANT ISSUE(S)

Resolves #475

DESCRIPTION

Add the remaining attributes for typeIndexJoin node that we want to see in the explainable response.

Example:

Request:

query @explain {
  author {
    _key
    name
    contact {
      email
      address {
      city
      }
    }
  }
}

Response:

{
  "explain": {
    "selectTopNode": {
      "renderNode": {
        "selectNode": {
          "filter": nil
          "typeIndexJoin": {
            "joinType":  "typeJoinOne"
            "direction": "primary"
            "rootName":  "author"
            "root": {
              "scanNode": {
                "filter":         nil
                "collectionID":   "3"
                "collectionName": "author"
                "spans": []{
                  {
                    "start": "/3"
                    "end":   "/4"
                  }
                }
              }
            }
            "subTypeName": "contact"
            "subType": {
              "selectTopNode": {
                "selectNode": {
                  "filter": nil
                  "typeIndexJoin": {
                    "joinType":  "typeJoinOne"
                    "direction": "primary"
                    "rootName":  "contact"
                    "root": {
                      "scanNode": {
                        "filter":         nil
                        "collectionID":   "4"
                        "collectionName": "authorContact"
                        "spans": []{
                          {
                            "start": "/4"
                            "end":   "/5"
                          }
                        }
                      }
                    }
                    "subTypeName": "address"
                    "subType": {
                      "selectTopNode": {
                        "selectNode": {
                          "filter": nil
                          "scanNode": {
                            "filter":         nil
                            "collectionID":   "5"
                            "collectionName": "contactAddress"
                            "spans": []{
                              {
                                "start": "/5"
                                "end":   "/6"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

HOW HAS THIS BEEN TESTED?

Added integration tests.

ENVIRONMENT / OS THIS WAS TESTED ON?

Please specify which of the following was this tested on (remove or add your own):

  • Arch Linux

@shahzadlone shahzadlone added feature New feature or request area/query Related to the query component action/no-benchmark Skips the action that runs the benchmark. labels Jun 3, 2022
@shahzadlone shahzadlone added this to the DefraDB v0.3 milestone Jun 3, 2022
@shahzadlone shahzadlone self-assigned this Jun 3, 2022
@codecov
Copy link

codecov bot commented Jun 3, 2022

Codecov Report

Merging #499 (ac22d78) into develop (954d22d) will increase coverage by 0.11%.
The diff coverage is 68.51%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #499      +/-   ##
===========================================
+ Coverage    54.20%   54.32%   +0.11%     
===========================================
  Files           97       97              
  Lines        13109    13158      +49     
===========================================
+ Hits          7106     7148      +42     
- Misses        5328     5331       +3     
- Partials       675      679       +4     
Impacted Files Coverage Δ
query/graphql/planner/explain.go 64.40% <53.84%> (-2.99%) ⬇️
query/graphql/planner/type_join.go 70.29% <72.50%> (+1.21%) ⬆️
query/graphql/planner/select.go 75.66% <100.00%> (ø)
query/graphql/parser/query.go 81.87% <0.00%> (+0.90%) ⬆️
query/graphql/planner/render.go 88.42% <0.00%> (+3.15%) ⬆️

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with a couple of non-blocking comments that would be good to get replies on. Looks good.

query/graphql/planner/explain.go Outdated Show resolved Hide resolved
tests/integration/query/explain/utils.go Outdated Show resolved Hide resolved
Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just need to add in the subType plan so both the root and the subtype scannodes show up.

query/graphql/planner/type_join.go Outdated Show resolved Hide resolved
@shahzadlone shahzadlone force-pushed the lone/feat/explain-type-index-join-attributes branch 4 times, most recently from 9bd91b6 to 1dcd00e Compare June 9, 2022 00:16
@shahzadlone shahzadlone requested a review from jsimnz June 9, 2022 00:17
@shahzadlone shahzadlone force-pushed the lone/feat/explain-type-index-join-attributes branch from 1dcd00e to 01a0b0e Compare June 9, 2022 04:30
Also Restructure root and subType explain graphs.
@shahzadlone shahzadlone force-pushed the lone/feat/explain-type-index-join-attributes branch from 01a0b0e to 80241c8 Compare June 9, 2022 04:35
Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looking great!

One weird thing I noticed in the typeIndexJoin attributes for the subType field. It's returning a selectTopNode without an innter selectNode, and instead goes straight into the next node, eg scanNode or another typeIndexJoin, etc.

I'm not sure if this is a problem in the explain code or the planner itself, but based on my review, the planner just called planner.SubSelect when making the subTypes, which just calls planner.Select but deletes the render step (since we do that at the end).

Let me know what you think after looking into it, and ping me if you need some insight/help.

}

// Add the attribute(s).
explainerMap[joinRootLabel] = joinType.subTypeFieldName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated to this PR, I guess we have some naming inconsistencies here w.r.t subTypeFieldNam actually coorepsonding to joinRootLabel.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't subTypeFieldName just be renamed to rootName? or am I missing something here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Trying to remember why it wasn't. Either way independant of this PR, so we don't need to resolve it atm

},
},

Results: []dataMap{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: The effort that went into all these test cases is 👌 * chefs kiss *

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gracias amigo!

tests/integration/query/explain/mix_test.go Outdated Show resolved Hide resolved
tests/integration/query/explain/mix_test.go Outdated Show resolved Hide resolved
tests/integration/query/explain/type_join_test.go Outdated Show resolved Hide resolved
@shahzadlone shahzadlone requested a review from jsimnz June 9, 2022 11:59
Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shahzadlone shahzadlone merged commit 8210564 into develop Jun 10, 2022
@shahzadlone shahzadlone deleted the lone/feat/explain-type-index-join-attributes branch June 10, 2022 15:19
shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
- RELEVANT ISSUE(S)

Resolves sourcenetwork#475 

- DESCRIPTION

Add the remaining attributes for `typeIndexJoin` node that we want to see in the explainable response.

Example:

Request:
```
query @Explain {
  author {
    _key
    name
    contact {
      email
      address {
      city
      }
    }
  }
}
```

Response: 
```
{
  "explain": {
    "selectTopNode": {
      "renderNode": {
        "selectNode": {
          "filter": nil
          "typeIndexJoin": {
            "joinType":  "typeJoinOne"
            "direction": "primary"
            "rootName":  "author"
            "root": {
              "scanNode": {
                "filter":         nil
                "collectionID":   "3"
                "collectionName": "author"
                "spans": []{
                  {
                    "start": "/3"
                    "end":   "/4"
                  }
                }
              }
            }
            "subTypeName": "contact"
            "subType": {
              "selectTopNode": {
                "selectNode": {
                  "filter": nil
                  "typeIndexJoin": {
                    "joinType":  "typeJoinOne"
                    "direction": "primary"
                    "rootName":  "contact"
                    "root": {
                      "scanNode": {
                        "filter":         nil
                        "collectionID":   "4"
                        "collectionName": "authorContact"
                        "spans": []{
                          {
                            "start": "/4"
                            "end":   "/5"
                          }
                        }
                      }
                    }
                    "subTypeName": "address"
                    "subType": {
                      "selectTopNode": {
                        "selectNode": {
                          "filter": nil
                          "scanNode": {
                            "filter":         nil
                            "collectionID":   "5"
                            "collectionName": "contactAddress"
                            "spans": []{
                              {
                                "start": "/5"
                                "end":   "/6"
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/query Related to the query component feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explain the attributes of typeIndexJoin.
3 participants