Uploaded image for project: 'Pentaho Analysis - Mondrian'
  1. Pentaho Analysis - Mondrian
  2. MONDRIAN-2152

Cell.getOrdinal() computes wrong ordinal if NonEmpty clause is present in MDX statement



    • Type: Improvement
    • Status: Open
    • Severity: Medium
    • Resolution: Unresolved
    • Affects Version/s: 3.6.0 (5.0.0 GA Suite Release)
    • Fix Version/s: Backlog
    • Component/s: None
    • Labels:
    • Notice:
      When an issue is open, the "Fix Version/s" field conveys a target, not necessarily a commitment. When an issue is closed, the "Fix Version/s" field conveys the version that the issue was fixed in.



      I'm using an embedded Mondrian 3.6.1 together with Pivot4J 0.9 to build a
      very simple OLAP web application. When performing drill through operations
      an exception occurs if a cell is addressed with its ordinal number and a NonEmpty
      clause is present in the MDX statement.

      In my case, the exception occurs because the ordinal number references a Cell that is
      beyond the dimensions of the result. However, the problem also exists for
      ordinal numbers within the given range as a wrong cell could be returned
      by CellSet.getCell(int).

      By default, the Pivot4J API uses the Cell ordinal as parameter to identify the
      cell to drill through in subsequent requests. If there is no NonEmpty clause
      everything works fine. A dump of a result with 2 columns and 6 rows prints
      the following cell coordinates and their ordinals:

      [0, 0] 0
      [1, 0] 1
      [0, 1] 2
      [1, 1] 3
      [0, 2] 4
      [1, 2] 5
      [0, 3] 6
      [1, 3] 7
      [0, 4] 8
      [1, 4] 9
      [0, 5] 10
      [1, 5] 11

      If I include a NonEmpty clause in the same statement, the cell coordinates are correct,
      but the ordinal numbers are not changed. In this example the rows with number 1 and 3
      are empty.

      [0, 0] 0
      [1, 0] 1
      [0, 1] 4
      [1, 1] 5
      [0, 2] 8
      [1, 2] 9
      [0, 3] 10
      [1, 3] 11

      However, if I call MondrianOlap4JCellSet.getCell(8) the operation results in an exception:

      java.lang.IndexOutOfBoundsException: Cell ordinal 8) lies outside CellSet bounds (2, 4)
      at mondrian.olap4j.MondrianOlap4jCellSet.ordinalToCoordinateArray(MondrianOlap4jCellSet.java:152)
      at mondrian.olap4j.MondrianOlap4jCellSet.getCell(MondrianOlap4jCellSet.java:138)

      Looking into the code some more, the first call to MondrianOlap4JCell.getOrdinal() finally results
      in mondrian.rolap.RolapResult.getCellOrdinal(int[]) being called. This results includes the empty
      rows. The later call to MondrianOlap4JCellSet.getCell(int) uses the private method int[] ordinalToCoordinateArray(int)
      to compute the coordinates. In this method result.getAxes() is used to get the axes and their sizes.
      However, the instance of "result" is RolapConnection$NonEmptyResult(ResultBase) and this
      result no longer contains the empty rows. Thus, the ordinal 8 is out of range.

      I think that MondrianOlap4JCell.getOrdinal() should not compute the ordinal number on the result
      that includes the empty rows.




            Unassigned Unassigned
            ap@allocation.net Prohaska Andreas
            2 Vote for this issue
            4 Start watching this issue