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: aggregations in structured views #57

Closed
mhordynski opened this issue Jun 19, 2024 · 0 comments · Fixed by #62
Closed

feat: aggregations in structured views #57

mhordynski opened this issue Jun 19, 2024 · 0 comments · Fixed by #62
Assignees
Labels
feature New feature or request

Comments

@mhordynski
Copy link
Member

Feature description

db-ally's structured views should support a new type of method exposed to the LLM called aggregation, in addition to the currently supported filters. Aggregations would allow the resulting query to be modified with a wrapper function that, for example, groups the results by dimension or calculates metrics.

Motivation

Often, users may ask questions such as:

  • What is the average number of years of experience for candidates in Europe?
  • What is the average amount spent on purchases by clients in the loyalty program, grouped by city?

Additional context

Based on our initial brainstorming session, we decided on the following:

  • Only one aggregation may be chosen for a given question.

  • Aggregations should be able to consume extra arguments (similar to filters). For example:

    @decorators.aggregation()
    def avg_amount_spent(self, grouped_by: Literal['city', 'country', 'gender']):
        ...
  • To ensure that the output schema is well-known, additional context should be added to the ExecutionResult class:

    ExecutionResult(
         view_name="CandidatesView",
         used_aggregation={
              "name": "avg_amount_spent",
              "args": {
                  "group_by": "city"
              }
         }
    )
@mhordynski mhordynski added the feature New feature or request label Jun 19, 2024
@mhordynski mhordynski moved this to Backlog in dbally 1.0 Jun 19, 2024
@mhordynski mhordynski moved this from Backlog to In progress in dbally 1.0 Jun 19, 2024
@micpst micpst linked a pull request Jun 24, 2024 that will close this issue
@mhordynski mhordynski moved this from In progress to In review in dbally 1.0 Jul 15, 2024
@micpst micpst assigned micpst and unassigned PatrykWyzgowski Aug 27, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in dbally 1.0 Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants