michaelmior commented on a change in pull request #1025: [CALCITE-2679] Fix a bug that `any_value` can't be used with other ag… URL: https://github.com/apache/calcite/pull/1025#discussion_r259329347
########## File path: elasticsearch/src/test/java/org/apache/calcite/adapter/elasticsearch/AggregationTest.java ########## @@ -257,6 +257,27 @@ public void anyValue() { .returnsUnordered("cat2=g; EXPR$1=y", // EXPR$1=null is also valid "cat2=h; EXPR$1=z"); + // combine any_value with other aggregation functions (eg. max) + CalciteAssert.that() + .with(newConnectionFactory()) + .query("select cat1, any_value(cat2), max(val1) from view group by cat1") + .returnsUnordered("cat1=a; EXPR$1=g; EXPR$2=1.0", + "cat1=null; EXPR$1=g; EXPR$2=null", + "cat1=b; EXPR$1=h; EXPR$2=7.0"); + + CalciteAssert.that() + .with(newConnectionFactory()) + .query("select max(val1), cat1, any_value(cat2) from view group by cat1") + .returnsUnordered("EXPR$0=1.0; cat1=a; EXPR$2=g", + "EXPR$0=null; cat1=null; EXPR$2=g", + "EXPR$0=7.0; cat1=b; EXPR$2=h"); + + CalciteAssert.that() + .with(newConnectionFactory()) + .query("select any_value(cat2), cat1, max(val1) from view group by cat1") + .returnsUnordered("EXPR$0=g; cat1=a; EXPR$2=1.0", + "EXPR$0=g; cat1=null; EXPR$2=null", + "EXPR$0=h; cat1=b; EXPR$2=7.0"); Review comment: These should probably be separate tests to make debugging easier if anything breaks them in the future. (I know initially there were already a couple asserts in the same tests, but if meaningful names can be given to each test, that would be great!) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services