xiedeyantu commented on code in PR #4371:
URL: https://github.com/apache/calcite/pull/4371#discussion_r2097562124


##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -354,6 +354,72 @@ private static boolean skipItem(RexNode expr) {
         .check();
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6887";>[CALCITE-6887]
+   * ReduceExpressionsRule applied to 'IN subquery' should make the values 
distinct
+   * if the subquery is a constant Values</a>. */
+  @Test void testAggregateValuesRuleWithInRepeatingValues() {
+    final String sql = "SELECT deptno, sal "
+        + "FROM EMP "
+        + "WHERE deptno IN (1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)";
+    sql(sql)
+        .withPreRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+        .withRule(CoreRules.AGGREGATE_VALUES_REDUCE)
+        .check();
+  }
+
+  @Test void testReduceInValuesWithNonOrder() {

Review Comment:
   You can just use `testAggregateValuesRuleWithInRepeatingValues` to show this 
logic.



##########
core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java:
##########
@@ -354,6 +354,72 @@ private static boolean skipItem(RexNode expr) {
         .check();
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6887";>[CALCITE-6887]
+   * ReduceExpressionsRule applied to 'IN subquery' should make the values 
distinct
+   * if the subquery is a constant Values</a>. */
+  @Test void testAggregateValuesRuleWithInRepeatingValues() {
+    final String sql = "SELECT deptno, sal "
+        + "FROM EMP "
+        + "WHERE deptno IN (1,1,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1)";
+    sql(sql)
+        .withPreRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+        .withRule(CoreRules.AGGREGATE_VALUES_REDUCE)
+        .check();
+  }
+
+  @Test void testReduceInValuesWithNonOrder() {
+    final String sql = "SELECT deptno, sal "
+        + "FROM EMP "
+        + "WHERE deptno IN (1,1,3,1,2)";
+
+    sql(sql)
+        .withPreRule(CoreRules.FILTER_SUB_QUERY_TO_CORRELATE)
+        .withRule(CoreRules.AGGREGATE_VALUES_REDUCE)
+        .checkUnchanged();
+  }
+
+  @Test void testAggregateValuesRuleWithRepeatingValues() {

Review Comment:
   Same as above.



-- 
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]

Reply via email to