mysticfall / pivot4j

Pivot4J provides a common API for OLAP servers which can be used to build an analytical service frontend with pivot style GUI.
Other
130 stars 99 forks source link

Error when rendering XLS for MDX with > 2 axes. #190

Open jazzido opened 9 years ago

jazzido commented 9 years ago

The following MDX query produces an ArrayIndexOutOfBoundsException in Mondrian 3.11:

SELECT NON EMPTY [Jurisdicciones].[Jurisdiccion].Members ON COLUMNS,
               NON EMPTY {[Measures].[Vigente], [Measures].[Devengado]} ON ROWS,
               NON EMPTY [Fecha].Year.Members ON PAGES
FROM [dataset_ejecucion_gastos_bahia_user_bahia]

Stack trace:

java.lang.ArrayIndexOutOfBoundsException: 2
mondrian.rolap.RolapConnection$NonEmptyResult.getCell(mondrian/rolap/RolapConnection.java:1023)
mondrian.olap4j.MondrianOlap4jCellSet.getCellInternal(mondrian/olap4j/MondrianOlap4jCellSet.java:171)
mondrian.olap4j.MondrianOlap4jCellSet.getCell(mondrian/olap4j/MondrianOlap4jCellSet.java:165)
org.pivot4j.ui.table.TableRenderer.renderDataRow(org/pivot4j/ui/table/TableRenderer.java:670)
org.pivot4j.ui.table.TableRenderer$3.handleTreeNode(org/pivot4j/ui/table/TableRenderer.java:638)
org.pivot4j.ui.table.TableHeaderNode.walkChildrenAtColIndex(org/pivot4j/ui/table/TableHeaderNode.java:891)
org.pivot4j.ui.table.TableHeaderNode.walkChildrenAtColIndex(org/pivot4j/ui/table/TableHeaderNode.java:907)
org.pivot4j.ui.table.TableRenderer.renderBody(org/pivot4j/ui/table/TableRenderer.java:597)
org.pivot4j.ui.table.TableRenderer.render(org/pivot4j/ui/table/TableRenderer.java:476)
mysticfall commented 9 years ago

I'm sorry that it took me for so long to answer. It's been quite hectic because of work recently.

Anyway, due to the 2 dimensional nature of the table renderer, it's not compatible with any result set which have more than 2 axes.

With your MDX example, we need 3 positions to identify a single cell, but currently the table renderer does not have any concept of 'pages', so it only assumes columns and rows positions, thus failing to retrieve cells.

Theoretically, this problem can be fixed by extending the current TableRenderer/Callback API as something like PagedTableRenderer/Callback, which defines required callback methods as startPage, endPage, etc with proper code to invoke them.

I'll leave it open as an issue, so it can be revisited in future.

Thanks for the reporting.