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 explainable renderLimitNode & hardLimitNode attributes. #614

Merged
merged 3 commits into from
Jul 12, 2022

Conversation

shahzadlone
Copy link
Member

Relevant issue(s)

Resolves #561

Description

Adds the limit and offset attributes for both renderLimitNode and hardLimitNode to be included in the returned explain graph response.

Example:

Request:

query @explain {
	author(limit: 3, offset: 1) {
		numberOfArts: _count(articles: {})
		articles(limit: 2) {
			name
		}
	}
}

Response:

{
  "data": [
    {
      "explain": {
        "selectTopNode": {
          "hardLimitNode": {
            "limit": 3,
            "offset": 1,
            "countNode": {
              "sources": [
                {
                  "fieldName": "articles",
                  "filter": null
                }
              ],
              "selectNode": {
                "filter": null,
                "typeIndexJoin": {
                  "joinType": "typeJoinMany",
                  "rootName": "author",
                  "root": {
                    "scanNode": {
                      "collectionID": "3",
                      "collectionName": "author",
                      "filter": null,
                      "spans": [
                        {
                          "end": "/4",
                          "start": "/3"
                        }
                      ]
                    }
                  },
                  "subTypeName": "articles",
                  "subType": {
                    "selectTopNode": {
                      "renderLimitNode": {
                        "limit": 2,
                        "offset": 0,
                        "selectNode": {
                          "filter": null,
                          "scanNode": {
                            "collectionID": "1",
                            "collectionName": "article",
                            "filter": null,
                            "spans": [
                              {
                                "end": "/2",
                                "start": "/1"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}

Tasks

  • I made sure the code is well commented, particularly in hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Integration tests locally and only CI. Specifically make test.

Specify the platform(s) on which this was tested:

  • Manjaro Flavor of Arch Linux Running in WSL2 on Windows 11

@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 Jul 9, 2022
@shahzadlone shahzadlone added this to the DefraDB v0.3 milestone Jul 9, 2022
@shahzadlone shahzadlone requested a review from a team July 9, 2022 16:25
@shahzadlone shahzadlone self-assigned this Jul 9, 2022
Description: "Explain Query Request With Only Offset Specified.",

Query: `query @explain {
author(offset: 2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not know we could do this lol

Copy link
Member Author

Choose a reason for hiding this comment

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

Was also first time finding out haha.

However not sure if that is the desired behavior?

Because if say you have a document in the collection, doing offset >= 1 (i.e. 1) will return no elements.

for example:

query {
	author(offset: 1) {
		name
	}
}

Regardless of the behavior probably discussion for outside the scope of this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

definitely outside of this PR lol, but we seem to be lacking tests for this - will create an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Appreciate it!

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.

LGTM

@shahzadlone shahzadlone force-pushed the lone/feat/explain-attributes-of-limit-nodes branch from 7d4a224 to 6741047 Compare July 12, 2022 05:13
@codecov
Copy link

codecov bot commented Jul 12, 2022

Codecov Report

Merging #614 (6741047) into develop (46ec563) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #614      +/-   ##
===========================================
+ Coverage    56.84%   56.90%   +0.05%     
===========================================
  Files          122      122              
  Lines        14595    14605      +10     
===========================================
+ Hits          8297     8311      +14     
+ Misses        5588     5584       -4     
  Partials       710      710              
Impacted Files Coverage Δ
query/graphql/planner/explain.go 68.96% <ø> (ø)
query/graphql/planner/limit.go 89.47% <100.00%> (+7.65%) ⬆️

@shahzadlone shahzadlone changed the title feat: Add ability to explain renderLimitNode and hardLimitNode attribute(s). feat: Add explainable renderLimitNode & hardLimitNode attributes. Jul 12, 2022
@shahzadlone shahzadlone merged commit 42b3209 into develop Jul 12, 2022
@shahzadlone shahzadlone deleted the lone/feat/explain-attributes-of-limit-nodes branch July 12, 2022 05:24
shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
…urcenetwork#614)

- Resolves: sourcenetwork#561 

- Description: Adds the `limit` and `offset` attributes for both `renderLimitNode` and `hardLimitNode` to be included in the returned explain graph response.

- Request:
```
query @Explain {
	author(limit: 3, offset: 1) {
		numberOfArts: _count(articles: {})
		articles(limit: 2) {
			name
		}
	}
}
```

- Response:
```
{
  "data": [
    {
      "explain": {
        "selectTopNode": {
          "hardLimitNode": {
            "limit": 3,
            "offset": 1,
            "countNode": {
              "sources": [
                {
                  "fieldName": "articles",
                  "filter": null
                }
              ],
              "selectNode": {
                "filter": null,
                "typeIndexJoin": {
                  "joinType": "typeJoinMany",
                  "rootName": "author",
                  "root": {
                    "scanNode": {
                      "collectionID": "3",
                      "collectionName": "author",
                      "filter": null,
                      "spans": [
                        {
                          "end": "/4",
                          "start": "/3"
                        }
                      ]
                    }
                  },
                  "subTypeName": "articles",
                  "subType": {
                    "selectTopNode": {
                      "renderLimitNode": {
                        "limit": 2,
                        "offset": 0,
                        "selectNode": {
                          "filter": null,
                          "scanNode": {
                            "collectionID": "1",
                            "collectionName": "article",
                            "filter": null,
                            "spans": [
                              {
                                "end": "/2",
                                "start": "/1"
                              }
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}
```
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 limit (renderLimitNode / hardLimitNode)
2 participants