Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.18.0
Description
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:
select state, city from zips group by state, city
After translation, adapter should return the following JSON:
{ "_source": false, "size": 0, "aggregations": { "g_state": { "terms": { "field": "state", "missing": "__MISSING__" }, "aggregations": { "g_city ": { "terms ": { "field ":"city ", "missing":"__MISSING__ " } } } } } }
But it returns the following JSON now:
{ "_source": ["state", "city"] }
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:
JsonNode agg = query;
while (agg.has(AGGREGATIONS) && agg.get(AGGREGATIONS).elements().hasNext()) {
agg = agg.get(AGGREGATIONS);
}
((ObjectNode) agg).remove(AGGREGATIONS);
But if input the JSON like above, this code will not work out.
Attachments
Issue Links
- links to