Pentaho Analysis - Mondrian
  1. Pentaho Analysis - Mondrian
  2. MONDRIAN-413

RolapMember causes ClassCastException in compare()

    Details

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

      Description

      This bug relates to mondrian 3.0.3.11016. There is an exception which occurs in RolapMember.compare(), line 713 in 3.0.3.11016.

      The compare() method may try to downcast the object key (byte[]) into a Comparable implementation, which causes the class cast exception. I suggest converting byte array keys to String objects before comparaison.


      A simple fix could be to inser this at line 713 :

      =================================================
      if (this.key instanceof byte[] && other.key instanceof byte[])
                   {
                    return Util.compareKey(new String((byte[])this.key), new String((byte[])other.key));
                   }
      =================================================

      I wasn't able to create a test case quickly. I don't have time to explore the test cube structure and find a way to make it generate byte array keys, but this solution was tested with my own installation and works like a charm.

      If you give me more details on the test suite architecture, I might look into it.



      Luc

        Activity

        Hide
        Mondrian Importer User added a comment -
        {lucboudreau}, 05/20/2008: Logged In: YES
        user_id=1363577
        Originator: YES

        Ok, I've found the root cause of all this. Using a varbinary field as a key creates this exception. I can't create a test case because this requires modifying the underlying database. As you mentioned, this is a big deal and is not something one simply does.

        The call is yours... anyways, I've modified my key type for something else.
        Show
        Mondrian Importer User added a comment - {lucboudreau}, 05/20/2008: Logged In: YES user_id=1363577 Originator: YES Ok, I've found the root cause of all this. Using a varbinary field as a key creates this exception. I can't create a test case because this requires modifying the underlying database. As you mentioned, this is a big deal and is not something one simply does. The call is yours... anyways, I've modified my key type for something else.
        Hide
        Mondrian Importer User added a comment -
        {jhyde}, 05/20/2008: Logged In: YES
        user_id=312935
        Originator: NO

        As I suggested, you could come up with testcase using an <InlineTable> element and a binary value like X'0123456789abcdef'. That should create a binary value on the fly.

        I know it's a hassle to create a testcase for a one-line fix. But I stand by the principle that every fix must have a testcase.
        Show
        Mondrian Importer User added a comment - {jhyde}, 05/20/2008: Logged In: YES user_id=312935 Originator: NO As I suggested, you could come up with testcase using an <InlineTable> element and a binary value like X'0123456789abcdef'. That should create a binary value on the fly. I know it's a hassle to create a testcase for a one-line fix. But I stand by the principle that every fix must have a testcase.
        Hide
        Mondrian Importer User added a comment -
        {lucboudreau}, 05/21/2008: Logged In: YES
        user_id=1363577
        Originator: YES

        I don't understand the X thing. I did this and it didn't work.

        final TestContext testContext = TestContext.createSubstitutingCube(
                    "Sales",
                    " <Dimension name=\"Binary\" foreignKey=\"promotion_id\">\n" +
                    " <Hierarchy name=\"Binary\" hasAll=\"true\" allMemberName=\"All Binaries\" primaryKey=\"promotion_id\">\n" +
                    " <InlineTable alias=\"binary\">\n" +
                    " <ColumnDefs>\n" +
                    " <ColumnDef name=\"id\" type=\"Numeric\"/>\n" +
                    " <ColumnDef name=\"name\" type=\"String\"/>\n" +
                    " </ColumnDefs>\n" +
                    " <Rows>\n" +
                    " <Row>\n" +
                    " <Value column=\"id\">X'2'</Value>\n" +
                    " <Value column=\"name\">X'asdf2'</Value>\n" +
                    " </Row>\n" +
        (.....)


        What did you mean by creating a binary value on the fly exactly ?
        Show
        Mondrian Importer User added a comment - {lucboudreau}, 05/21/2008: Logged In: YES user_id=1363577 Originator: YES I don't understand the X thing. I did this and it didn't work. final TestContext testContext = TestContext.createSubstitutingCube(             "Sales",             " <Dimension name=\"Binary\" foreignKey=\"promotion_id\">\n" +             " <Hierarchy name=\"Binary\" hasAll=\"true\" allMemberName=\"All Binaries\" primaryKey=\"promotion_id\">\n" +             " <InlineTable alias=\"binary\">\n" +             " <ColumnDefs>\n" +             " <ColumnDef name=\"id\" type=\"Numeric\"/>\n" +             " <ColumnDef name=\"name\" type=\"String\"/>\n" +             " </ColumnDefs>\n" +             " <Rows>\n" +             " <Row>\n" +             " <Value column=\"id\">X'2'</Value>\n" +             " <Value column=\"name\">X'asdf2'</Value>\n" +             " </Row>\n" + (.....) What did you mean by creating a binary value on the fly exactly ?
        Hide
        Mondrian Importer User added a comment -
        {jhyde}, 05/21/2008: Logged In: YES
        user_id=312935
        Originator: NO

        The 'X thing' is the SQL standard way to create a binary string literal. According to this bug (http://bugs.mysql.com/bug.php?id=35658) MySQL supports them. If you are using another database it's possible your database does not support this syntax; use whatever mechanism your database provides to create binary string literals.
        Show
        Mondrian Importer User added a comment - {jhyde}, 05/21/2008: Logged In: YES user_id=312935 Originator: NO The 'X thing' is the SQL standard way to create a binary string literal. According to this bug ( http://bugs.mysql.com/bug.php?id=35658 ) MySQL supports them. If you are using another database it's possible your database does not support this syntax; use whatever mechanism your database provides to create binary string literals.
        Hide
        Mondrian Importer User added a comment -
        {jhyde}, 07/08/2008: Logged In: YES
        user_id=312935
        Originator: NO

        Fixed in change 11282. Will be in mondrian-3.0.4.
        Show
        Mondrian Importer User added a comment - {jhyde}, 07/08/2008: Logged In: YES user_id=312935 Originator: NO Fixed in change 11282. Will be in mondrian-3.0.4.

          People

          • Assignee:
            Julian Hyde
            Reporter:
            Luc Boudreau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: