You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Siyuan Liu (JIRA)" <ji...@apache.org> on 2019/02/02 17:49:00 UTC
[jira] [Commented] (CALCITE-2679) Group by without aggregation
function cannot be translated to correct JSON in Elasticsearch Adapter
[ https://issues.apache.org/jira/browse/CALCITE-2679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16759133#comment-16759133 ]
Siyuan Liu commented on CALCITE-2679:
-------------------------------------
Fixed in PR: [https://github.com/apache/calcite/pull/1025|https://github.com/apache/calcite/pull/1025,]
> 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)