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

SQL: COUNT(DISTINCT [field_name]) generates "Two sibling aggregations cannot have the same name" error #30287

Closed
astefan opened this issue May 1, 2018 · 2 comments

Comments

@astefan
Copy link
Contributor

astefan commented May 1, 2018

Test index mapping with no documents:

PUT ip_index2
{
  "mappings": {
    "_doc": {
      "properties": {
        "source": {
          "type":"text",
          "fields": {
            "keyword": {
              "type":"keyword"
            }
          }
        },
        "country": {
          "type": "keyword"
        }
      }
    }
  }
}

The following query select source,count(distinct country) from ip_index2 group by source having count(distinct country)>5 generates an error:

Server error [Server sent bad type [illegal_argument_exception]. Original type was [Two sibling aggregations cannot have the same name: [1777]]. [java.lang.IllegalArgumentException: Two sibling aggregations cannot have the same name: [1777]
@astefan astefan added the :Analytics/SQL SQL querying label May 1, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@colings86 colings86 added the >bug label May 2, 2018
@alexfrancoeur
Copy link

alexfrancoeur commented Aug 28, 2018

I've run into this with queries in Canvas as well

SELECT FLOOR(SUM(FlightTimeMin)/1440) as total_days, (365-(FLOOR(SUM(FlightTimeMin)/1440))) as "days_leftover"
FROM kibana_sample_data_flights

costin added a commit to costin/elasticsearch that referenced this issue Aug 29, 2018
Prevent generation of duplicate aggs caused by repetitive functions,
leading to invalid query.

Fix elastic#30287
costin added a commit that referenced this issue Aug 30, 2018
Prevent generation of duplicate aggs caused by repetitive functions,
leading to invalid query.

Fix #30287
costin added a commit that referenced this issue Aug 30, 2018
Prevent generation of duplicate aggs caused by repetitive functions,
leading to invalid query.

Fix #30287

(cherry picked from commit 83c3d7a)
costin added a commit that referenced this issue Aug 30, 2018
Prevent generation of duplicate aggs caused by repetitive functions,
leading to invalid query.

Fix #30287

(cherry picked from commit 83c3d7a)
(cherry picked from commit 61e0ce7)
@jimczi jimczi added v7.0.0-beta1 and removed v7.0.0 labels Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants