[ https://issues.apache.org/jira/browse/CALCITE-2689?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrei Sereda updated CALCITE-2689: ----------------------------------- Description: For [Terms Aggregation|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html] missing value has to have same type as group key: {code:sql} select max(amount), date from orders group by date -- date column is of type date (in ES) {code} Currently single (text) key is used {{__MISSING__}} which fails when grouping on non-string fields (eg. dates, numbers or booleans). When using {{missing}} (value) query converter should consider field type. This logic should be reviewed once we migrate to [composite aggregations|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html] (available since [6.1|https://www.elastic.co/guide/en/elasticsearch/reference/6.1/release-notes-6.1.0.html] see PR[26800|https://github.com/elastic/elasticsearch/pull/26800]) was: For [Terms Aggregation|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html] missing value has to have same type as group key. Currently single (text) key is used {{__MISSING__}} which fails when grouping on non-string fields (eg. dates, numbers or booleans). When using {{missing}} (value) query converter should consider field type. This logic should be reviewed once we migrate to [composite aggregations|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html] (available since [6.1|https://www.elastic.co/guide/en/elasticsearch/reference/6.1/release-notes-6.1.0.html] see PR[26800|https://github.com/elastic/elasticsearch/pull/26800]) > ES Adapter. Grouping on date / number fields fails > -------------------------------------------------- > > Key: CALCITE-2689 > URL: https://issues.apache.org/jira/browse/CALCITE-2689 > Project: Calcite > Issue Type: Improvement > Components: elasticsearch-adapter > Reporter: Andrei Sereda > Assignee: Julian Hyde > Priority: Major > > For [Terms > Aggregation|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html] > missing value has to have same type as group key: > {code:sql} > select max(amount), date from orders group by date -- date column is of type > date (in ES) > {code} > Currently single (text) key is used {{__MISSING__}} which fails when grouping > on non-string fields (eg. dates, numbers or booleans). > When using {{missing}} (value) query converter should consider field type. > This logic should be reviewed once we migrate to [composite > aggregations|https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-composite-aggregation.html] > (available since > [6.1|https://www.elastic.co/guide/en/elasticsearch/reference/6.1/release-notes-6.1.0.html] > see PR[26800|https://github.com/elastic/elasticsearch/pull/26800]) -- This message was sent by Atlassian JIRA (v7.6.3#76005)