Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.0-incubating
    • Fix Version/s: 1.4.0-incubating
    • Component/s: None
    • Labels:
      None
    • Environment:

      Windows x64, MongoDB , JDK 1.7

      Description

      When using with Mondrian 4.2 and With MongoDB (foodmart data),
      The following exception is raised.

      Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
      at org.apache.calcite.avatica.util.AbstractCursor$LongAccessor.getLong(AbstractCursor.java:483)
      at org.apache.calcite.avatica.util.AbstractCursor$AccessorImpl.getInt(AbstractCursor.java:252)
      at org.apache.calcite.avatica.AvaticaResultSet.getInt(AvaticaResultSet.java:248)
      at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
      at org.apache.commons.dbcp.DelegatingResultSet.getInt(DelegatingResultSet.java:225)
      at mondrian.spi.impl.SqlStatisticsProvider.getTableCardinality(SqlStatisticsProvider.java:52)
      at mondrian.rolap.RolapSchema$PhysStatistic.getTableCardinality(RolapSchema.java:2888)
      at mondrian.rolap.RolapSchema$PhysStatistic.getRelationCardinality(RolapSchema.java:2860)
      at mondrian.rolap.RolapSchema$PhysTable.populateColumns(RolapSchema.java:1859)
      at mondrian.rolap.RolapSchema$PhysRelationImpl.ensurePopulated(RolapSchema.java:1519)
      at mondrian.rolap.RolapSchema$PhysTable.ensurePopulated(RolapSchema.java:1729)
      at mondrian.rolap.RolapSchemaUpgrader.toPhysRelation(RolapSchemaUpgrader.java:1866)
      at mondrian.rolap.RolapSchemaUpgrader.convertCube(RolapSchemaUpgrader.java:179)
      at mondrian.rolap.RolapSchemaUpgrader.convertSchema(RolapSchemaUpgrader.java:2208)
      at mondrian.rolap.RolapSchemaUpgrader.upgrade(RolapSchemaUpgrader.java:125)
      at mondrian.rolap.RolapSchemaLoader.loadStage0(RolapSchemaLoader.java:254)
      at mondrian.rolap.RolapSchemaLoader.createSchema(RolapSchemaLoader.java:4303)
      at mondrian.rolap.RolapSchemaPool.get(RolapSchemaPool.java:210)
      at mondrian.rolap.RolapSchemaPool.get(RolapSchemaPool.java:62)
      at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:160)
      at mondrian.rolap.RolapConnection.<init>(RolapConnection.java:84)
      at mondrian.olap.DriverManager.getConnection(DriverManager.java:112)
      at mondrian.olap.DriverManager.getConnection(DriverManager.java:68)
      at mondrian.olap.DriverManager.getConnection(DriverManager.java:50)
      at ....

        Activity

        Hide
        jnadeau Jacques Nadeau added a comment -

        Resolved in release 1.4.0-incubating (2015-08-23)

        Show
        jnadeau Jacques Nadeau added a comment - Resolved in release 1.4.0-incubating (2015-08-23)
        Hide
        piers.harding Piers added a comment -

        Tested OK - thanks.

        Cheers,
        Piers Harding.

        Show
        piers.harding Piers added a comment - Tested OK - thanks. Cheers, Piers Harding.
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/dbdb091d .
        Hide
        piers.harding Piers added a comment -

        As a test I hacked in this change:

        diff --git a/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java b/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
        index 9786c7a..88b252c 100644
        --- a/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
        +++ b/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
        @@ -501,7 +501,12 @@ public LongAccessor(Getter getter) {
             }
         
             public long getLong() {
        -      Long o = (Long) super.getObject();
        +      Long o = null;
        +      if (super.getObject() instanceof Long) {
        +        o = (Long) super.getObject();
        +      } else if (super.getObject() instanceof Integer) {
        +        o = new Long((Integer) super.getObject());
        +      }
               return o == null ? 0 : o;
             }
           }
        

        Which works - it seems like it is something to do with the return type on the

         count(*) 

        , but I haven't been able to figure that out yet.

        Show
        piers.harding Piers added a comment - As a test I hacked in this change: diff --git a/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java b/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java index 9786c7a..88b252c 100644 --- a/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java +++ b/avatica/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java @@ -501,7 +501,12 @@ public LongAccessor(Getter getter) { } public long getLong() { - Long o = ( Long ) super .getObject(); + Long o = null ; + if ( super .getObject() instanceof Long ) { + o = ( Long ) super .getObject(); + } else if ( super .getObject() instanceof Integer ) { + o = new Long (( Integer ) super .getObject()); + } return o == null ? 0 : o; } } Which works - it seems like it is something to do with the return type on the count(*) , but I haven't been able to figure that out yet.
        Hide
        piers.harding Piers added a comment -


        current HEAD I think - https://github.com/apache/incubator-calcite.git ec9d966042f870c70593fca9e8bf55f8f74317e9

        Show
        piers.harding Piers added a comment - current HEAD I think - https://github.com/apache/incubator-calcite.git ec9d966042f870c70593fca9e8bf55f8f74317e9
        Hide
        julianhyde Julian Hyde added a comment -

        What version of Calcite?

        Show
        julianhyde Julian Hyde added a comment - What version of Calcite?
        Hide
        piers.harding Piers added a comment -

        Hi -
        I think I hit a similar problem when following the example here http://calcite.incubator.apache.org/docs/howto.html#mongodb-adapter - using latest head from incubator-calcite on Ubuntu Vivid with a vanilla Mongo install. When I get to the point in the example "sqlline> select count from zips; " - I get the following error:

          0: jdbc:calcite:model=mongodb/target/test-cla> select count(*) from zips;
          +---------------------+
          |       EXPR$0        |
          +---------------------+
          java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long
        	at org.apache.calcite.avatica.util.AbstractCursor$LongAccessor.getLong(AbstractCursor.java:504)
        	at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:305)
        	at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:381)
        	at sqlline.Rows$Row.<init>(Rows.java:157)
        	at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63)
        	at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
        	at sqlline.SqlLine.print(SqlLine.java:1652)
        	at sqlline.Commands.execute(Commands.java:833)
        	at sqlline.Commands.sql(Commands.java:732)
        	at sqlline.SqlLine.dispatch(SqlLine.java:807)
        	at sqlline.SqlLine.begin(SqlLine.java:681)
        	at sqlline.SqlLine.start(SqlLine.java:398)
        	at sqlline.SqlLine.main(SqlLine.java:292)
          0: jdbc:calcite:model=mongodb/target/test-cla> 
        

        Thanks,
        Piers Harding.

        Show
        piers.harding Piers added a comment - Hi - I think I hit a similar problem when following the example here http://calcite.incubator.apache.org/docs/howto.html#mongodb-adapter - using latest head from incubator-calcite on Ubuntu Vivid with a vanilla Mongo install. When I get to the point in the example "sqlline> select count from zips; " - I get the following error: 0: jdbc:calcite:model=mongodb/target/test-cla> select count(*) from zips; +---------------------+ | EXPR$0 | +---------------------+ java.lang.ClassCastException: java.lang. Integer cannot be cast to java.lang. Long at org.apache.calcite.avatica.util.AbstractCursor$LongAccessor.getLong(AbstractCursor.java:504) at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:305) at org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:381) at sqlline.Rows$Row.<init>(Rows.java:157) at sqlline.IncrementalRows.hasNext(IncrementalRows.java:63) at sqlline.TableOutputFormat.print(TableOutputFormat.java:33) at sqlline.SqlLine.print(SqlLine.java:1652) at sqlline.Commands.execute(Commands.java:833) at sqlline.Commands.sql(Commands.java:732) at sqlline.SqlLine.dispatch(SqlLine.java:807) at sqlline.SqlLine.begin(SqlLine.java:681) at sqlline.SqlLine.start(SqlLine.java:398) at sqlline.SqlLine.main(SqlLine.java:292) 0: jdbc:calcite:model=mongodb/target/test-cla> Thanks, Piers Harding.
        Hide
        nareshjois Naresh Jois added a comment -

        I have imported the MongoDB JSON data from - https://github.com/julianhyde/foodmart-data-json
        I am using the MongoDB connector that comes with calcite (Model-Used : <src>/mongodb/target/test-classes/mongo-foodmart-model.json)

        I am using the Foodmart Schema of mondrian (I tried using both Schema of both versions 4 & 3)
        I am not using an ad-hoc SQL Query, I am just using the following code to make a connection

        String connectionString = getConnectionString();
        RolapConnection connection = (RolapConnection)DriverManager.getConnection(connectionString, null);
        RolapSchema schema = connection.getSchema();
        RolapCube cube = (RolapCube) schema.lookupCube("Warehouse",false);
        

        Please excuse me if I am missing something fairly obvious, but what do you refer to as built-in MongoDB instance ?
        Please do let me know if any other information is needed,

        Show
        nareshjois Naresh Jois added a comment - I have imported the MongoDB JSON data from - https://github.com/julianhyde/foodmart-data-json I am using the MongoDB connector that comes with calcite (Model-Used : <src>/mongodb/target/test-classes/mongo-foodmart-model.json) I am using the Foodmart Schema of mondrian (I tried using both Schema of both versions 4 & 3) I am not using an ad-hoc SQL Query, I am just using the following code to make a connection String connectionString = getConnectionString(); RolapConnection connection = (RolapConnection)DriverManager.getConnection(connectionString, null ); RolapSchema schema = connection.getSchema(); RolapCube cube = (RolapCube) schema.lookupCube( "Warehouse" , false ); Please excuse me if I am missing something fairly obvious, but what do you refer to as built-in MongoDB instance ? Please do let me know if any other information is needed,
        Hide
        julianhyde Julian Hyde added a comment -

        What is the SQL query? Are you able to reproduce this on Calcite's built-in MongoDB instance?

        Show
        julianhyde Julian Hyde added a comment - What is the SQL query? Are you able to reproduce this on Calcite's built-in MongoDB instance?

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            nareshjois Naresh Jois
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development