Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Aggregation on Nested Array Field return unexpected value #187

Closed
penghuo opened this issue Sep 19, 2019 · 0 comments
Closed

Aggregation on Nested Array Field return unexpected value #187

penghuo opened this issue Sep 19, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@penghuo
Copy link
Contributor

penghuo commented Sep 19, 2019

The aggregatioin on nested array field return unexpected value.
SQL

    SELECT e.name, COUNT(p) as count
    FROM employee_nested_it AS e, e.projects AS p
    GROUP BY e.name

Test data: https://github.com/opendistro-for-elasticsearch/sql/blob/master/src/test/resources/employee_nested.json

Expected Result

      "buckets" : [
        {
          "key" : "Bob Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 3,
            "count" : {
              "value" : 3
            }
          }
        },
        {
          "key" : "Jane Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 2,
            "count" : {
              "value" : 2
            }
          }
        },
        {
          "key" : "John Doe",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 0,
            "count" : {
              "value" : 0
            }
          }
        },
        {
          "key" : "Susan Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 0,
            "count" : {
              "value" : 0
            }
          }
        }
      ]

Actual Result

      "buckets" : [
        {
          "key" : "Bob Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 3,
            "count" : {
              "value" : 0
            }
          }
        },
        {
          "key" : "Jane Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 2,
            "count" : {
              "value" : 0
            }
          }
        },
        {
          "key" : "John Doe",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 0,
            "count" : {
              "value" : 0
            }
          }
        },
        {
          "key" : "Susan Smith",
          "doc_count" : 1,
          "projects@NESTED" : {
            "doc_count" : 0,
            "count" : {
              "value" : 0
            }
          }
        }
     ]
@penghuo penghuo added the bug Something isn't working label Sep 19, 2019
@penghuo penghuo self-assigned this Sep 19, 2019
@penghuo penghuo closed this as completed Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant