[ https://issues.apache.org/jira/browse/CALCITE-2679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16706432#comment-16706432 ]
Julian Hyde edited comment on CALCITE-2679 at 12/4/18 12:45 AM: ---------------------------------------------------------------- Fixed in [d7d28a27|http://git-wip-us.apache.org/repos/asf/calcite/commit/d7d28a27]; thanks for the PR, [~Functor10]! was (Author: julianhyde): Fixed in [96605a86|http://git-wip-us.apache.org/repos/asf/calcite/commit/96605a86]; thanks for the PR, [~Functor10]! > Group by without aggregation function cannot be translated to correct JSON in > Elasticsearch Adapter > --------------------------------------------------------------------------------------------------- > > Key: CALCITE-2679 > URL: https://issues.apache.org/jira/browse/CALCITE-2679 > Project: Calcite > Issue Type: Bug > Components: elasticsearch-adapter > Affects Versions: 1.18.0 > Reporter: Siyuan Liu > Assignee: Julian Hyde > Priority: Major > Labels: easyfix > Fix For: 1.18.0 > > > The Elasticsearch Adapter of the current master branch has some problems when > querying for group by clause without aggregation function. For example, when > I query the following SQL: > {code:sql} > select state, city from zips group by state, city > {code} > After translation, adapter should return the following JSON: > {code:json} > { > "_source": false, > "size": 0, > "aggregations": { > "g_state": { > "terms": { > "field": "state", > "missing": "__MISSING__" > }, > "aggregations": { > "g_city ": { > "terms ": { > "field ":"city ", > "missing":"__MISSING__ " > } > } > } > } > } > } > {code} > But it returns the following JSON now: > {code:sql} > { > "_source": ["state", "city"] > } > {code} > The reason for this problem is that there is a missing condition for judging > the aggregation query. > In addition, there is the other associated problem. After building > aggregation JSON, the code of current version will remove empty aggregation > block in ElasticsearchTable class, the code just like this: > {code:java} > JsonNode agg = query; > while (agg.has(AGGREGATIONS) && agg.get(AGGREGATIONS).elements().hasNext()) { > agg = agg.get(AGGREGATIONS); > } > ((ObjectNode) agg).remove(AGGREGATIONS); > {code} > But if input the JSON like above, this code will not work out. -- This message was sent by Atlassian JIRA (v7.6.3#76005)