Skip to content

[BUG] fields is changing the outcome of the following commands that depend on selected fields #2739

Closed

Description

@TackAdam

What is the bug?
When running stats count() operation on a nested parameter the result seems to just return 0. If the field is specified before running the count, it will show the correct value.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Go to 'OpenSearch Playground:Query Workbench https://playground.opensearch.org/app/opensearch-query-workbench#/
  2. Click on PPL and enter the PPL "source = jaeger-span-* |stats count (references.refType)" and hit Run
Screenshot 2024-06-11 at 4 34 36 PM -Output will be 0

Enter the PPL "source = jaeger-span-* | fields references.refType|stats count (references.refType)" and hit Run
Screenshot 2024-06-11 at 4 36 22 PM
-Output will be 193

What is the expected behavior?
The stats count() should return a consistent value regardless of any preceeding field selection.

What is your host/environment?

  • OS: [e.g. iOS]
  • Version [e.g. 22]
  • Plugins

Do you have any screenshots?
If applicable, add screenshots to help explain your problem.

Do you have any additional context?
Add any other context about the problem.

Activity

  1. added
    bug
    on Jun 11, 2024
  2. LantaoJin commented on Jun 14, 2024

    @LantaoJin
    Member

    This may be not a bug of SQL plugin. Regarding to nested field, OpenSearch DSL query will return 0 value too. Try below DSL

    GET jaeger-span-*/_search
    {
      "size": 0,
      "aggs": {
        "count_refType": {
          "value_count": {
            "field": "references.refType"
          }
        }
      }
    }
    

    PPL source = jaeger-span-* | stats count (references.refType) equals to above DSL query. But source = jaeger-span-* | fields references.refType | stats count (references.refType) equals searching keyword patients.name first then aggregate.

  3. LantaoJin commented on Jun 14, 2024

    @LantaoJin
    Member
  4. dblock commented on Jul 1, 2024

    @dblock
    Member

    Is this fixed with the related OpenSearch issue @LantaoJin?

    [Catch All Triage - Attendees 1, 2, 3, 4, 5]

  5. LantaoJin commented on Jul 9, 2024

    @LantaoJin
    Member

    Is this fixed with the related OpenSearch issue @LantaoJin?

    No. It's not an OpenSearch Core bug. The aggregation query on a nested field should build Nested Aggregations builder, but in our v2 engine, the information of nested field is missing during expression analysis. We mistakenly use an normal aggregation builder to query on a nested field, rather than nested aggregation builder. I'm investigating how to store the nested field information in expression analyzing and trigger nested aggregation builder in v2.

  6. added
    catch-all acknowledged
    on Jan 7, 2025
  7. LantaoJin commented on May 27, 2025

    @LantaoJin
    Member

    #2814 is stalled, I am going to raise another PR to fix this issue for PPL first.

  8. added
    PPL
    and removed
    catch-all acknowledged
    on May 29, 2025
  9. self-assigned this
    on Jun 27, 2025
  10. LantaoJin commented on Jan 5, 2026

    @LantaoJin
    Member

    Resolved by #4979

  11. moved this from Not Started to Done in PPL Trackeron Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

PPLbug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions