opensearch-project / opensearch-project/sql

[BUG] Cannot pushdown a nested root as group-by key

Open
#5,006 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance PPL pushdown
Dominant language
Java
Stars
176
Forks
229
Avg merge
2d 21h
Merged PRs (30d)
43

Description

Query Information

PPL Command/Query:

source=test | stats count() by rec
source=test | top rec
source=test | dedup rec

Dataset Information

Dataset/Schema Type

  • OpenTelemetry (OTEL)
  • Simple Schema for Observability (SS4O)
  • Open Cybersecurity Schema Framework (OCSF)
  • Custom (details below)

Index Mapping

{
  "mappings": {
    "properties": {
      "rec": {
        "type": "nested",
        "properties": {
          "inner": {
            "type": "integer"
          }
        }
      }
    }
  }
}

Sample Data

{"rec":{"inner": 100}}
{"rec":{"inner": 101}}
{"rec":{"inner": 101}}

Bug Description

Issue Summary:
The queries above will try to trigger an aggregation pushdown which the group-by key (bucket) is rec. Since rec is a nested root, OpenSeach DSL returns null if the bucket fields is a nested field. So it will fallback to execute in Calcite EnumerableAggregate which may have performance issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the three PPL queries and the nested mapping shown in the issue, then trace how aggregation pushdown handles the group-by key rec. Verify behavior against the OpenSearch DSL result and the Calcite EnumerableAggregate fallback. Done means nested-root grouping no longer produces an unusable pushdown result and the affected queries behave correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.