You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "1fanwang (via GitHub)" <gi...@apache.org> on 2026/08/25 18:34:40 UTC

[PR] [CALCITE-6089] Add regression tests for groupless sorted aggregate [calcite]

1fanwang opened a new pull request, #5222:
URL: https://github.com/apache/calcite/pull/5222

   ## Jira Link
   
   [CALCITE-6089](https://issues.apache.org/jira/browse/CALCITE-6089)
   
   ## Changes Proposed
   
   Counting rows over a `UNION ALL` failed at runtime when the sorted aggregate was
   used:
   
   ```
   java.lang.ClassCastException: class java.lang.Integer cannot be cast to class
   org.apache.calcite.runtime.FlatLists$ComparableList
   ```
   
   The query now returns `c=4`.
   
   The aggregate has no group key. The rule used to convert it anyway, and
   comparing the zero-length keys threw. CALCITE-6087 made the rule decline an
   empty group set, so no sorted aggregate is produced, the planner uses the
   regular aggregate, and the query succeeds. That fix therefore closed this issue
   too, so this PR adds only the regression tests requested when #5202 merged.
   
   Two tests, following the pattern that patch established. One forces the sorted
   rule and asserts the planner now rejects the plan; the other runs the query with
   the usual rule set and asserts the result.
   
   ### Testing
   
   Running the suite on this branch, which is current main plus the two new tests:
   
   ```console
   $ ./gradlew :core:test --tests '*EnumerableSortedAggregateTest'
   15 completed, 0 failed, 0 skipped
   BUILD SUCCESSFUL
   ```
   
   Reverting only the one-line rule change from CALCITE-6087, and keeping the new
   tests, reproduces the original failure:
   
   ```console
   $ git checkout bd65b15fc6^ -- core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableSortedAggregateRule.java
   $ ./gradlew :core:test --tests '*EnumerableSortedAggregateTest.sortedAggCountUnion*'
   FAILURE sortedAggCountUnionRejectsEmptyGroupSet()
     but: was "java.sql.SQLException: Error while executing SQL ...:
     class java.lang.Integer cannot be cast to class
     org.apache.calcite.runtime.FlatLists$ComparableList"
   2 completed, 1 failed
   ```
   
   ## Are there any user-facing changes?
   
   No. Tests only.
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #5222:
URL: https://github.com/apache/calcite/pull/5222#discussion_r3868875332


##########
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java:
##########
@@ -74,6 +74,40 @@ public class EnumerableSortedAggregateTest {
         .throws_("There are not enough rules to produce a node with desired properties");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-6089">[CALCITE-6089]
+   * EnumerableSortedAggregate fails with ClassCastException: class X cannot be
+   * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>.
+   *
+   * <p>The aggregate has no group key, so since

Review Comment:
   Agreed, and that paragraph is already out. The revision after your review cut the explanation of the old behaviour and left the Javadoc as the issue link alone.
   
   What the two tests assert now is current behaviour rather than history. One shows the rule declining the plan when the aggregate has no group key, the other shows the default rules producing the right count for the same query.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5222:
URL: https://github.com/apache/calcite/pull/5222#issuecomment-5420936403

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #5222:
URL: https://github.com/apache/calcite/pull/5222#issuecomment-5416668812

   please squash the commits for merging


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #5222:
URL: https://github.com/apache/calcite/pull/5222#discussion_r3856254408


##########
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java:
##########
@@ -74,6 +74,40 @@ public class EnumerableSortedAggregateTest {
         .throws_("There are not enough rules to produce a node with desired properties");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-6089">[CALCITE-6089]
+   * EnumerableSortedAggregate fails with ClassCastException: class X cannot be
+   * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>.
+   *
+   * <p>The aggregate has no group key, so since

Review Comment:
   I don't think we care about what used to happen previously. We are not keeping a log of all past bugs.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5222:
URL: https://github.com/apache/calcite/pull/5222#issuecomment-5415245759

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #5222:
URL: https://github.com/apache/calcite/pull/5222


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #5222:
URL: https://github.com/apache/calcite/pull/5222#issuecomment-5415559941

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=5222&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=5222&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=5222&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=5222)
   
   


-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #5222:
URL: https://github.com/apache/calcite/pull/5222#discussion_r3875130296


##########
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java:
##########
@@ -74,6 +74,40 @@ public class EnumerableSortedAggregateTest {
         .throws_("There are not enough rules to produce a node with desired properties");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-6089">[CALCITE-6089]
+   * EnumerableSortedAggregate fails with ClassCastException: class X cannot be
+   * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>.
+   *
+   * <p>The aggregate has no group key, so since

Review Comment:
   ack, dropped the reference



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [CALCITE-6089] EnumerableSortedAggregate fails with ClassCastException: class X cannot be cast to class org.apache.calcite.runtime.FlatLists$ComparableList [calcite]

Posted by "1fanwang (via GitHub)" <gi...@apache.org>.
1fanwang commented on code in PR #5222:
URL: https://github.com/apache/calcite/pull/5222#discussion_r3868875332


##########
core/src/test/java/org/apache/calcite/test/enumerable/EnumerableSortedAggregateTest.java:
##########
@@ -74,6 +74,40 @@ public class EnumerableSortedAggregateTest {
         .throws_("There are not enough rules to produce a node with desired properties");
   }
 
+  /** Test case for
+   * <a href="https://issues.apache.org/jira/browse/CALCITE-6089">[CALCITE-6089]
+   * EnumerableSortedAggregate fails with ClassCastException: class X cannot be
+   * cast to class org.apache.calcite.runtime.FlatLists$ComparableList</a>.
+   *
+   * <p>The aggregate has no group key, so since

Review Comment:
   Agreed, and that paragraph is already out. The revision after your review cut the explanation of the old behaviour and left the Javadoc as the issue link alone.
   
   What the two tests assert now is current behaviour rather than history. One shows the rule declining the plan when the aggregate has no group key, the other shows the default rules producing the right count for the same query.



-- 
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: commits-unsubscribe@calcite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org