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

refactor: Change terminology from query to request #1054

Merged
merged 27 commits into from
Jan 26, 2023

Conversation

shahzadlone
Copy link
Member

@shahzadlone shahzadlone commented Jan 24, 2023

RELEVANT ISSUE(S)

Resolves #455

DESCRIPTION

This PR changes existing terminology to comply with the following terminology definitions:

DefraDB Terminology:

  • (1) Request is the top-level term that encapsulates all the operations (query and mutation ops).
  • (2) Query Request or Request Query are same as (1) but only for situations where we need to use the word "Query" for some reason (say for external use for example in cli package), so the Request descriptor clarifies the type of "Query" this is.
  • (3) Query Operation implies that the request is a "read-only request", but note that if we loosely say Query Request that does not mean a read-only operation according to (2).
  • (4) Query loosely the same as (3), BUT STRONGLY AVOID USING ON IT'S OWN.
  • (5) Mutation Operation implies that the request is a "write request".
  • (6) Mutation Request implies that the request's operation is of type mutation. Note: (6) and (5) can be used interchangeably but (2) and (3) can not.
  • (7) Mutation is loosely the same as (5) and (6) but avoid using this term.

With the above definition, we can use other descriptors to specify the type of request it is, for example: "Explain request" or "Subscription Request". But the only gotcha / confusing rule we need to worry about is that Query Request is not the same as Query Operation. The use of the word Query with another descriptor assumes (4), for example: Query Plan is a plan that is made from a read-only query.

Throughout the codebase (excluding 3rd party stuff, eg. ipfs), we should avoid the use of (2), (4), and (7) to avoid confusion. The only exception to (4) I can see is when we say "Defra Query Language" (because this is not referring to the query operation).

@shahzadlone shahzadlone requested a review from a team January 24, 2023 17:41
@shahzadlone shahzadlone self-assigned this Jan 24, 2023
@shahzadlone shahzadlone added documentation Improvements or additions to documentation refactor This issue specific to or requires *notable* refactoring of existing codebases and components code quality Related to improving code quality labels Jan 24, 2023
@shahzadlone shahzadlone added this to the DefraDB v0.5 milestone Jan 24, 2023
@codecov
Copy link

codecov bot commented Jan 24, 2023

Codecov Report

Merging #1054 (5856242) into develop (8dd7f84) will increase coverage by 0.07%.
The diff coverage is 71.04%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1054      +/-   ##
===========================================
+ Coverage    68.03%   68.10%   +0.07%     
===========================================
  Files          171      172       +1     
  Lines        16250    16250              
===========================================
+ Hits         11055    11067      +12     
+ Misses        4261     4251      -10     
+ Partials       934      932       -2     
Impacted Files Coverage Δ
api/http/errors.go 100.00% <ø> (ø)
cli/root.go 48.23% <ø> (ø)
client/descriptions.go 84.61% <ø> (ø)
client/document.go 64.25% <ø> (ø)
client/request/select.go 100.00% <ø> (ø)
client/request/subscription.go 100.00% <ø> (ø)
db/collection.go 65.87% <ø> (ø)
db/collection_delete.go 29.41% <0.00%> (ø)
db/db.go 72.47% <ø> (ø)
db/fetcher/versioned.go 56.11% <ø> (ø)
... and 33 more

- Rename the folder.
- Update all import modules that need updating due to the rename.
- Update a comment that needed updating.
- Update the `request/` package name.
- Rename `planner/query.go` file to `planner/request.go`.
- Rename the type `planner.Query` to `planner.Request`.
- Update a comment about `ExecQuery` (which will soon be changed).
NOTE: Some instances are left as `query` as this is more user facing.
Change to `PostSubscriptionRequests` & `TransactionalRequests`
@shahzadlone shahzadlone force-pushed the lone/refactor/change-query-term-to-request branch from 87a8a2c to e5c70aa Compare January 24, 2023 17:52
@source-devs

This comment was marked as spam.

@shahzadlone shahzadlone added the action/no-benchmark Skips the action that runs the benchmark. label Jan 24, 2023
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 - thanks a bunch for sorting this out Shahzad, would suggest merging this really aggressively to mimimize any conflicts (including for those working on other branches that will be affected by this merge)

@orpheuslummis
Copy link
Contributor

trivia: etymologically, request and query come from the same quaerō (latin) which essentially means to want

Copy link
Contributor

@orpheuslummis orpheuslummis left a comment

Choose a reason for hiding this comment

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

LGTM but there are a lot of repetitive lines that I went through quickly

I saw a non-gofmt-ed notice, that would be good to fix it before it's merged.

tests/integration/utils.go Outdated Show resolved Hide resolved
@orpheuslummis
Copy link
Contributor

I saw a non-gofmt-ed notice, that would be good to fix it before it's merged.

I think you fixed it already in a later commit

@shahzadlone shahzadlone force-pushed the lone/refactor/change-query-term-to-request branch from d91f4cd to e55a45b Compare January 24, 2023 21:49
@@ -19,5 +19,5 @@ import (
)

var (
log = logging.MustNewLogger("defra.query.schema")
log = logging.MustNewLogger("defra.request.schema")
Copy link
Member Author

Choose a reason for hiding this comment

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

question: Should this be defra.request.graphql.schema instead @jsimnz ?

Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: This is a very large PR that could potentially disrupt other developers. Keeping these changes in isolation for the sake of very minor stuff like this is not going to help things and will increase the likelihood of it costing any of us time. The question you asked is not really specific to this PR (issue existed before), and can easily be sorted out after the many lines that this PR changes have been merged.

Copy link
Member Author

Choose a reason for hiding this comment

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

Understand your concern and agree with not delaying this PR, John is reviewing it as we speak so thought will ask a question I had before I forget. This shouldn't really effect the speed of this PR merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that this PR moves several files/directories that I am actively working with (including new files which definitely will not be auto-magically handled by git).

Additionally, IMO a rename PR on an item that has already been agreed upon (and reviewed in draft format) really doesnt need 3 approvals, and had I known that the majority of the dev team was going to review it prior to merge I would not have felt that adding my review to that list would have been worth the time that I spent on this.

Copy link
Member Author

Choose a reason for hiding this comment

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

It isn't that it needs 3 approvals, but more that if someone is taking a look at it then why not wait for them to finish the review?

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.

Approving for now as my suggestions aren't necessarily for blocking. Some are just for seeding discussion as well as indexing of thoughts.

Two primary concerns (again non blocking) - There is some minor confusion regarding what a "request" is, as "request" is also used to refer to "query operation" as well as the top level GQL request.

Second, one thing we didn't reach too much consensus on regarding this change is the goals highlighted in #864 of seperating GQL from the Defra Query layer. This PR changes that conversation a bit to refer to all Defra Query layer as Requests, when in reality this change was caused by the GQL confusion specifically.

Non blocking, but wanted to see what ppl think
cc: @AndrewSisley since he started #864

db/collection_delete.go Outdated Show resolved Hide resolved
db/collection_update.go Outdated Show resolved Hide resolved
db/collection_update.go Outdated Show resolved Hide resolved
Comment on lines -13 to +20
// Query is an external hook into the planNode
// RequestPlan is an external hook into the planNode
// system. It allows outside packages to
// execute and manage a query plan graph directly.
// execute and manage a request plan graph directly.
// Instead of using one of the available functions
// like ExecQuery(...).
// like ExecRequest(...).
// Currently, this is used by the collection.Update
// system.
type Query planNode
type RequestPlan planNode
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: Can likely be just Request, since the package name is planner, so written it would be planner.Request which more succinct then planner.RequestPlan.

Likely why it was just Query instead of QueryPlan before.

Copy link
Member Author

Choose a reason for hiding this comment

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

This file was previously called query.go, by your suggestion this file would be called request.go? Would like to avoid using request.go file for plan stuff.

I would also suggest that the planNode is more a plan than a request at this stage (as the request will be converted into a plan by the time this type is used IRRC).

IMO planner.Request is still ambiguous, can be easily confused as a request to the planner for example. As planner is something that "creates a plan", and plan is the actual graph of steps.

package query
package request
Copy link
Member

Choose a reason for hiding this comment

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

I'm somewhat hesitant to rename this package since the terminology confusion/replacement imo is scoped to GQL. Fundementally this is still the "DefraDB Query Language" - of which we have GQL Requests, which contains a GQL Query Operation.

This somewhat goes along with a discussion previously regarding the seperation of GQL from the Query interface #864.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have linked this as a thing to discuss in #864, as this is non-blocking we can discuss and change it back if needed.

@shahzadlone
Copy link
Member Author

shahzadlone commented Jan 26, 2023

Approving for now as my suggestions aren't necessarily for blocking. Some are just for seeding discussion as well as indexing of thoughts.

Thanks appreciate the planting of seeds that will grow into fruitful discussions.

Two primary concerns (again non blocking) - There is some minor confusion regarding what a "request" is, as "request" is also used to refer to "query operation" as well as the top level GQL request.

This is a good question, let me see if I can clarify the definitions according to this PR:

According to GQL:

Request
 | --> Query Operation
 | --> | --> Selection Set
 | --> Mutation Operation
 | --> | --> Selection Set

DefraDB Terminology:
(1) Request is the top-level term that encapsulates all the operations (query and mutation ops).
(2) Query Request or Request Query are same as (1) but only for situations where we need to use the word "Query" for some reason (say for external use for example in cli package), so the Request descriptor clarifies the type of "Query" this is.
(3) Query Operation implies that the request is a "read-only request", but note that if we loosely say Query Request that does not mean a read-only operation according to (2).
(4) Query loosely the same as (3), BUT STRONGLY AVOID USING ON IT'S OWN.
(5) Mutation Operation implies that the request is a "write request".
(6) Mutation Request implies that the request's operation is of type mutation. Note: (6) and (5) can be used interchangeably but (2) and (3) can not.
(7) Mutation is loosely the same as (5) and (6) but avoid using this term.

With the above definition, we can use other descriptors to specify the type of request it is, for example: "Explain request" or "Subscription Request". But the only gotcha / confusing rule we need to worry about is that Query Request is not the same as Query Operation. The use of the word Query with another descriptor assumes (4), for example Query Plan is a plan that is made from a read-only query.

IMO in the code base (excluding 3rd party stuff, eg. ipfs), we should avoid the use of (2), (4), and (7) to avoid confusion. The only exception to (4) I can see is when we say "Defra Query Language", but to be fair even the Q in GQL stands for query haha.

One other benefit of using these definitions is that, while they work "nicely" (maybe not perfectly) with GQL it still gives us the control to keep the terminology consistent across other query languages as we add support for them.

Second, one thing we didn't reach too much consensus on regarding this change is the goals highlighted in #864 of seperating GQL from the Defra Query layer. This PR changes that conversation a bit to refer to all Defra Query layer as Requests, when in reality this change was caused by the GQL confusion specifically.

Non blocking, but wanted to see what ppl think cc: @AndrewSisley since he started #864

This PR should comply the definition rules I defined above, if you notice any rules were broken we can change that easily in the later PR, and hope this will help keep things in harmony for #864 as well, the more reason to not depend on terms only dependent on a specific query language.

@shahzadlone shahzadlone merged commit 93ea57a into develop Jan 26, 2023
@shahzadlone shahzadlone deleted the lone/refactor/change-query-term-to-request branch January 26, 2023 11:27
shahzadlone added a commit that referenced this pull request Apr 13, 2023
- Resolves #455

- DESCRIPTION:

This PR changes existing terminology to comply with the following terminology definitions:

DefraDB Terminology:
* (1) `Request` is the top-level term that encapsulates all the operations (`query` and `mutation` ops).
* (2) `Query Request` or `Request Query` are same as (1) but only for situations where we need to use the word "Query" for some reason (say for external use for example in `cli` package), so the `Request` descriptor clarifies the type of "Query" this is.
* (3) `Query Operation` implies that the request is a "read-only request", but note that if we loosely say `Query Request` that does not mean a read-only operation according to (2).
* (4) `Query` loosely the same as (3), BUT STRONGLY AVOID USING ON IT'S OWN.
* (5) `Mutation Operation` implies that the request is a "write request".
* (6) `Mutation Request` implies that the request's operation is of type `mutation`. Note: `(6)` and `(5)` can be used interchangeably but `(2)` and `(3)` can not.
* (7) `Mutation` is loosely the same as (5) and (6) but avoid using this term.
 
With the above definition, we can use other descriptors to specify the type of request it is, for example: "Explain request" or "Subscription Request". But the only gotcha / confusing rule we need to worry about is that `Query Request` is not the same as `Query Operation`. The use of the word `Query` with another descriptor assumes (4), for example: `Query Plan` is a plan that is made from a read-only query.  

Throughout the codebase (excluding 3rd party stuff, eg. ipfs), we should avoid the use of (2), (4), and (7) to avoid confusion. The only exception to (4) I can see is when we say "Defra Query Language" (because this is not referring to the query operation).
shahzadlone added a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
- Resolves sourcenetwork#455

- DESCRIPTION:

This PR changes existing terminology to comply with the following terminology definitions:

DefraDB Terminology:
* (1) `Request` is the top-level term that encapsulates all the operations (`query` and `mutation` ops).
* (2) `Query Request` or `Request Query` are same as (1) but only for situations where we need to use the word "Query" for some reason (say for external use for example in `cli` package), so the `Request` descriptor clarifies the type of "Query" this is.
* (3) `Query Operation` implies that the request is a "read-only request", but note that if we loosely say `Query Request` that does not mean a read-only operation according to (2).
* (4) `Query` loosely the same as (3), BUT STRONGLY AVOID USING ON IT'S OWN.
* (5) `Mutation Operation` implies that the request is a "write request".
* (6) `Mutation Request` implies that the request's operation is of type `mutation`. Note: `(6)` and `(5)` can be used interchangeably but `(2)` and `(3)` can not.
* (7) `Mutation` is loosely the same as (5) and (6) but avoid using this term.
 
With the above definition, we can use other descriptors to specify the type of request it is, for example: "Explain request" or "Subscription Request". But the only gotcha / confusing rule we need to worry about is that `Query Request` is not the same as `Query Operation`. The use of the word `Query` with another descriptor assumes (4), for example: `Query Plan` is a plan that is made from a read-only query.  

Throughout the codebase (excluding 3rd party stuff, eg. ipfs), we should avoid the use of (2), (4), and (7) to avoid confusion. The only exception to (4) I can see is when we say "Defra Query Language" (because this is not referring to the query operation).
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. code quality Related to improving code quality documentation Improvements or additions to documentation refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactoring All Query Request Terminology to be change to Request
5 participants