[ https://issues.apache.org/jira/browse/CALCITE-4130?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrei Sereda updated CALCITE-4130: ----------------------------------- Fix Version/s: (was: 1.25.0) > Aggregation function in order by clause will throw exception in elasticsearch > adapter > ------------------------------------------------------------------------------------- > > Key: CALCITE-4130 > URL: https://issues.apache.org/jira/browse/CALCITE-4130 > Project: Calcite > Issue Type: Bug > Components: elasticsearch-adapter > Affects Versions: 1.25.0 > Reporter: yuqi > Priority: Major > Labels: pull-request-available > Time Spent: 1h > Remaining Estimate: 0h > > For sql like > {code:java} > select id, count(id) from test group by id order by count(id) > {code} > When execute query, `ElasticsearchTable#aggregate` will throw exception like > {code:java} > Caused by: java.lang.IllegalArgumentException: Field EXPR$1 not defined for > aggs > {code} > Reproduce: > {code:java} > Add test as below in AggregationTest > CalciteAssert.that() > .with(newConnectionFactory()) > .query("select cat2, count(cat2) from view group by cat2 order by > count(cat2)") > .returnsUnordered("cat2=g; EXPR$1=2", > "cat2=h; EXPR$1=1"); > {code} > result: > {code:java} > Caused by: java.lang.IllegalArgumentException: Field EXPR$1 not defined for > aggs > at > org.apache.calcite.adapter.elasticsearch.ElasticsearchMapping.missingValueFor(ElasticsearchMapping.java:84) > at > org.apache.calcite.adapter.elasticsearch.ElasticsearchTable.aggregate(ElasticsearchTable.java:235) > at > org.apache.calcite.adapter.elasticsearch.ElasticsearchTable.find(ElasticsearchTable.java:130) > at > org.apache.calcite.adapter.elasticsearch.ElasticsearchTable.access$000(ElasticsearchTable.java:70) > at > org.apache.calcite.adapter.elasticsearch.ElasticsearchTable$ElasticsearchQueryable.find(ElasticsearchTable.java:411) > at Baz.bind(Unknown Source) > at > org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:355) > at > org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:315) > at > org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:507) > at > org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:498) > at > org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:182) > at > org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:64) > at > org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:43) > at > org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:667) > at > org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:567) > at > org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675) > at > org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) > ... 68 more > {code} > till now, this problem can only be found in elasticsearch adapter -- This message was sent by Atlassian Jira (v8.3.4#803005)