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

Olap4j's method toOlap4j throws NPE if we have a function

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Severe Severe
    • Resolution: Unresolved
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • QA Validation Status:
      Not Yet Validated

      Description

      In MondrianOlap4jConnection, method toOlap4j, we have:

              } else if (type instanceof mondrian.olap.type.MemberType) {
                  final mondrian.olap.type.MemberType memberType =
                      (mondrian.olap.type.MemberType) type;
                  return new MemberType(
                      toOlap4j(memberType.getDimension()),
                      toOlap4j(memberType.getHierarchy()),
                      toOlap4j(memberType.getLevel()),
                      toOlap4j(memberType.getMember()));
              }


      if that memberType is given by a calc which is a function, getDimension returns null, giving a NPE in the end.

      This query on foodmart triggers it:

      SELECT
      NON EMPTY {Hierarchize({[Measures].[Customer Count]})} ON COLUMNS,
      CurrentDateMember([Time], """[Time].[Year].[1997]""")
      ON ROWS
      FROM [Sales 2]

        Activity

        Hide
        Paul Stoellberger added a comment -
        reproducable like that:


        String mdx = "SELECT
        NON EMPTY {Hierarchize({[Measures].[Customer Count]})} ON COLUMNS, CurrentDateMember([Time], \"[Time].[Year].[1997]\") ON ROWS FROM [Sales 2]";
                final MdxParserFactory parserFactory =
                    connection.getParserFactory();
                MdxParser mdxParser =
                    parserFactory.createMdxParser(connection);
                MdxValidator mdxValidator =
                    parserFactory.createMdxValidator(connection);

        SelectNode select = mdxParser.parseSelect(mdx);
        SelectNode validatedSelect = mdxValidator.validateSelect(select);


        Show
        Paul Stoellberger added a comment - reproducable like that: String mdx = "SELECT NON EMPTY {Hierarchize({[Measures].[Customer Count]})} ON COLUMNS, CurrentDateMember([Time], \"[Time].[Year].[1997]\") ON ROWS FROM [Sales 2]";         final MdxParserFactory parserFactory =             connection.getParserFactory();         MdxParser mdxParser =             parserFactory.createMdxParser(connection);         MdxValidator mdxValidator =             parserFactory.createMdxValidator(connection); SelectNode select = mdxParser.parseSelect(mdx); SelectNode validatedSelect = mdxValidator.validateSelect(select);
        Hide
        Julian Hyde added a comment -
        Cannot reproduce. Query works fine when run through olap4j.
        Show
        Julian Hyde added a comment - Cannot reproduce. Query works fine when run through olap4j.
        Hide
        Paul Stoellberger added a comment -
        So this affects the mdx parser + validator (MondrianOlap4jMdxValidator)
        Show
        Paul Stoellberger added a comment - So this affects the mdx parser + validator (MondrianOlap4jMdxValidator)
        Hide
        Paul Stoellberger added a comment -
        Yes, the query executes fine, its the mdx validator that does that
        Show
        Paul Stoellberger added a comment - Yes, the query executes fine, its the mdx validator that does that
        Hide
        Paul Stoellberger added a comment -
        I added a test case in olap4j to ConnectionTest.java that runs fine in current olap4j (not sure which mondrian its using) but fails with TRUNK-SNAPSHOT (master branch of mondrian)

            /**
             * Tests creation of an MDX parser, and validating an MDX statement
             * and turning it into a parse tree.
             *
             */
            public void testFunctionParsing() throws SQLException {
                connection = tester.createConnection();
                OlapConnection olapConnection =
                    tester.getWrapper().unwrap(connection, OlapConnection.class);
                MdxParser mdxParser =
                    olapConnection.getParserFactory().createMdxParser(olapConnection);
                MdxValidator mdxValidator =
                 olapConnection.getParserFactory().createMdxValidator(olapConnection);

                SelectNode select =
                    mdxParser.parseSelect(
                        "SELECT "
                     + "NON EMPTY {[Measures].[Customer Count]} ON COLUMNS, "
                     + "CurrentDateMember([Time], \"[Time].[Year].[1997]\") "
                     + "ON ROWS FROM [Sales 2] ");

                mdxValidator.validateSelect(select);
            }
        Show
        Paul Stoellberger added a comment - I added a test case in olap4j to ConnectionTest.java that runs fine in current olap4j (not sure which mondrian its using) but fails with TRUNK-SNAPSHOT (master branch of mondrian)     /**      * Tests creation of an MDX parser, and validating an MDX statement      * and turning it into a parse tree.      *      */     public void testFunctionParsing() throws SQLException {         connection = tester.createConnection();         OlapConnection olapConnection =             tester.getWrapper().unwrap(connection, OlapConnection.class);         MdxParser mdxParser =             olapConnection.getParserFactory().createMdxParser(olapConnection);         MdxValidator mdxValidator =          olapConnection.getParserFactory().createMdxValidator(olapConnection);         SelectNode select =             mdxParser.parseSelect(                 "SELECT "              + "NON EMPTY {[Measures].[Customer Count]} ON COLUMNS, "              + "CurrentDateMember([Time], \"[Time].[Year].[1997]\") "              + "ON ROWS FROM [Sales 2] ");         mdxValidator.validateSelect(select);     }
        Hide
        Paul Stoellberger added a comment -
        of course i meant the mondrian version that comes with olap4j

        i exchanged the default testlib/mondrian.jar with the trunk snapshot one

        Show
        Paul Stoellberger added a comment - of course i meant the mondrian version that comes with olap4j i exchanged the default testlib/mondrian.jar with the trunk snapshot one

          People

          • Assignee:
            Unassigned User
            Reporter:
            Pedro Alves
          • Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: