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 count aggregate support #102

Merged
merged 2 commits into from
Jan 13, 2022

Conversation

AndrewSisley
Copy link
Contributor

@AndrewSisley AndrewSisley commented Dec 22, 2021

Closes #93

Adds count aggregate support within object and commit queries. Adjusts the render system slightly, introducing a new _hidden field allowing records to be yielded through nodes, but not outputted to the query consumer (in this case, it saves a lot of hassle when counting with a limit/offset on the child collection).

  • Have talk on many-nodes vs aggregate node
  • Update Tech-doc post merge

@AndrewSisley AndrewSisley added feature New feature or request area/query Related to the query component labels Dec 22, 2021
@AndrewSisley AndrewSisley self-assigned this Dec 22, 2021
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.

A few comments/thoughts/issues.

Biggest gripe is the implementation of aggregate funcs as individual planNodes. We can talk about this during the next call.

query/graphql/parser/query.go Show resolved Hide resolved
query/graphql/parser/query.go Outdated Show resolved Hide resolved
query/graphql/parser/query.go Show resolved Hide resolved
query/graphql/planner/aggregate_count.go Outdated Show resolved Hide resolved
"github.com/sourcenetwork/defradb/query/graphql/parser"
)

type countNode struct {
Copy link
Member

Choose a reason for hiding this comment

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

I mentioned this briefly in the convo on #28... My reservation about making each aggregate func its own dedicated node is that it will inflate the plan graph notably for queries that use a notable number of aggregates. Especially if youre thinking about composing aggregates out of other aggregates (IE: Avg from Sum and Count).

Especially if to implement a single aggregate func, we need to define an entire planNode with methods that have very little to do with the process of aggregation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't worry so much about the size of the graph, and the graph would remain as flat as it would otherwise be (something I do see as fairly important). They are independent, and there should be very little overhead involved, even when composing - avg could use the output from sum and count inline (with the downside of having to ensure sum and count are run first in the planner).

But we should talk later on this as you said.

query/graphql/planner/limit.go Outdated Show resolved Hide resolved
query/graphql/planner/planner.go Show resolved Hide resolved
@AndrewSisley AndrewSisley force-pushed the sisley/feat/I93-aggregate-count branch 7 times, most recently from b1dfea3 to 804f4d0 Compare January 7, 2022 21:53
@AndrewSisley
Copy link
Contributor Author

I believed we agreed to defer the architectural decision on many vs one aggregate node(s) until we have at least one more node. I've added a comment on this in the countNode, planner and selectNode

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.

Comments/responses all look good to me! Stoked to have the first aggregate in!

@AndrewSisley AndrewSisley force-pushed the sisley/feat/I93-aggregate-count branch from 804f4d0 to 63d9397 Compare January 13, 2022 16:34
@AndrewSisley AndrewSisley merged commit 5369942 into develop Jan 13, 2022
@AndrewSisley AndrewSisley deleted the sisley/feat/I93-aggregate-count branch January 13, 2022 16:36
@orpheuslummis orpheuslummis mentioned this pull request Jan 29, 2022
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
* Add count aggregate support to object querys

* Add count aggregate support to commit queries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Aggregate: Count
2 participants