Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-1097

Exception when executing query with too many aggregation columns

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.0
    • Fix Version/s: 1.7.0
    • Component/s: core
    • Labels:
      None

      Description

      When executing a query like the following:
      select s."cust_id", sum(s."prod_id"), sum(s."prod_id_1"), ......, sum(s."prod_id_194"), sum(s."prod_id_195"), sum(s."prod_id_196"), sum(s."prod_id_197"), sum(s."prod_id_198"), sum(s."prod_id_199")
      from "foodmart"."table" as s group by s."cust_id"

      Calcite reports exception as followed:
      Exception in thread "main" java.sql.SQLException: Error while executing SQL
      Error while compiling generated Java code:
      public static class Record200_0 implements java.io.Serializable {
      .....
      Caused by: org.codehaus.janino.JaninoRuntimeException: Baz$2.apply(): Operand stack overflow at offset 1195
      at org.codehaus.janino.CodeContext.flowAnalysis(CodeContext.java:490)

      Tracking down the error in EnumerableAggregate, I found that this is because Calcite generates a class with a constructor which has as many parameters as the aggregated fields, and the auto-generated java code causes error while being compiled.
      There is not a certain number of constructor number, since it seems the longest length of constructor parameter also relates to the java type of the parameters.

        Activity

        Hide
        chenzhifa@mininglamp.com chenzhifa added a comment -

        I have a fix in here: https://github.com/apache/calcite/pull/198
        I have added a new test to cover it and all tests have passed.

        Show
        chenzhifa@mininglamp.com chenzhifa added a comment - I have a fix in here: https://github.com/apache/calcite/pull/198 I have added a new test to cover it and all tests have passed.
        Hide
        julianhyde Julian Hyde added a comment -

        Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/5fdc866b. chenzhifa, Thanks for the PR! I agree with you diagnosis of the cause of the bug, and your fix, and I appreciate the detailed test case. I refactored your test case a little.

        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/5fdc866b . chenzhifa , Thanks for the PR! I agree with you diagnosis of the cause of the bug, and your fix, and I appreciate the detailed test case. I refactored your test case a little.
        Hide
        chenzhifa@mininglamp.com chenzhifa added a comment -

        Thanks Julian! Glad that I helped! And thanks a lot for refactoring the test case, it looks much better.

        Show
        chenzhifa@mininglamp.com chenzhifa added a comment - Thanks Julian! Glad that I helped! And thanks a lot for refactoring the test case, it looks much better.
        Hide
        julianhyde Julian Hyde added a comment -

        Resolved in release 1.7.0 (2016-03-22).

        Show
        julianhyde Julian Hyde added a comment - Resolved in release 1.7.0 (2016-03-22).

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            chenzhifa@mininglamp.com chenzhifa
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development