cjj2010 commented on code in PR #4774:
URL: https://github.com/apache/calcite/pull/4774#discussion_r2762785205
##########
mongodb/src/test/java/org/apache/calcite/adapter/mongodb/MongoAdapterTest.java:
##########
@@ -1046,4 +1046,51 @@ private static Consumer<List> mongoChecker(final
String... expected) {
"{$group:{_id:{},_0:{$min:'$POP'}}}",
"{$project:{EXPR$0:{$abs:['$_0']}}}"));
}
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7404">[CALCITE-7404]
+ * Incorrect Field Alias in MongoDB project Stage</a>. */
+ @Test void testAggFunctionMinFilter() {
+ assertModel(MODEL)
+ .query("select min(pop>5000) as pop_result from zips")
+ .queryContains(
+ mongoChecker(
+ "{$project:{_0:{$gt:['$pop',{$literal:5000}]}}}",
+ "{$group:{_id: {},POP_RESULT:{$min:'$_0'}}}"))
+ .returns("POP_RESULT=false\n");
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7404">[CALCITE-7404]
+ * Incorrect Field Alias in MongoDB project Stage</a>. */
+ @Test void testAliasNameOrderBy() {
+ assertModel(MODEL)
+ .query("select pop as pop_a from zips"
+ + " order by pop_a")
+ .limit(3)
+ .queryContains(
+ mongoChecker(
+ "{$project:{POP_A:'$pop'}}",
+ "{$sort: {POP_A: 1}}"))
+ .returnsOrdered("POP_A=21",
+ "POP_A=17522",
+ "POP_A=22576");
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-7404">[CALCITE-7404]
+ * Incorrect Field Alias in MongoDB project Stage</a>. */
+ @Test void testNameOrderBy() {
Review Comment:
> The same as above?
This is mainly to verify whether there is a difference between the order by
alias and the order by original table field
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]