Skip to content

[FEATURE] Support nested aggregation #2813

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

Open
LantaoJin opened this issue Jul 10, 2024 · 0 comments · May be fixed by #3696
Open

[FEATURE] Support nested aggregation #2813

LantaoJin opened this issue Jul 10, 2024 · 0 comments · May be fixed by #3696
Labels
enhancement New feature or request PPL Piped processing language

Comments

@LantaoJin
Copy link
Member

LantaoJin commented Jul 10, 2024

Is your feature request related to a problem?
In order to interact with nested fields in an aggregation, a nested aggregation must be used.
OpenSearch DSL query:

GET logs/_search
{
  "query": {
    "match": { "response": "200" }
  },
  "aggs": {
    "pages": {
      "nested": {
        "path": "pages"
      },
      "aggs": {
        "min_load_time": { "min": { "field": "pages.load_time" } }
      }
    }
  }
}

Translated OpenSearch SQL query:

SELECT min(nested(pages.load_time, pages)) FROM logs WHERE response = 200;

However, above nested aggregation query hasn't supported yet in SQL plugin. Aggregation on nested fields directly will lead to incorrect results. Some related issues: #2739, #2529

What solution would you like?
Support nested aggregation with follow syntaxes:
SQL: agg_func(nested(field | [field, path]))
PPL: | stats agg_func(nested(field | [field, path]))

What alternatives have you considered?
For PPL query, an alternative to calculate aggregation on nested field is searching out all nested field data then aggregate:

source = jaeger-span-* | fields references.refType | stats count(references.refType)

For SQL query:

SELECT count(t.temp) FROM
   (SELECT nested(references.refType, references) as temp FROM jaeger-span-*) t

But both of them have performance problem and the results are limited by memory and query_size parameters.

Do you have any additional context?
Add any other context or screenshots about the feature request here.

@LantaoJin LantaoJin added enhancement New feature or request untriaged labels Jul 10, 2024
@LantaoJin LantaoJin changed the title [WIP][FEATURE] Support nested aggregation [FEATURE] Support nested aggregation Jul 10, 2024
@LantaoJin LantaoJin linked a pull request May 29, 2025 that will close this issue
7 tasks
@penghuo penghuo added the PPL Piped processing language label May 29, 2025
@penghuo penghuo added this to PPL 2025 May 30, 2025
@github-project-automation github-project-automation bot moved this to Not Started in PPL 2025 May 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PPL Piped processing language
Projects
Status: Not Started
2 participants