Correct support for non-numeric measure values
d-amelin opened this issue · comments
I'm facing a problem with string measure value. There is a calculated measure 'Units' that give string value to display units (eg "kg."):
WITH MEMBER [Measures].[Units] AS [Indicator].CurrentMember.Properties("Units") SELECT {[Measures].[Units], [Measures].[Value] }....
but I got the following error:
at org.pivot4j.ui.table.TableRenderer.getValue(TableRenderer.java:217) at org.pivot4j.ui.table.TableRenderer.renderDataRow(TableRenderer.java:727) .... Caused by: org.olap4j.OlapException: not a number at mondrian.olap4j.MondrianOlap4jConnection$Helper.createException(MondrianOlap4jConnection.java:808) at mondrian.olap4j.MondrianOlap4jCell.getDoubleValue(MondrianOlap4jCell.java:101) at org.pivot4j.ui.table.TableRenderer.getValue(TableRenderer.java:215) ....
There are same issue: Support for non-numeric measure values. #147 https://github.com/mysticfall/pivot4j/issues/147
fixed with commit: https://github.com/mysticfall/pivot4j/commit/0920002af73f4f67986f8a1a248257a885f76059
but that fix is not enought for me:
- fix expects that cell.getDoubleValue() will raise NumberFormatException
- this expectation is true for org.olap4j.driver.xmla.XmlaOlap4jCell.getDoubleValue.
it raises NumberFormatException, as seen in #147 first post. - this expectation is not correct for mondrian.olap4j.MondrianOlap4jCell.getDoubleValue
it raises org.olap4j.OlapException. See https://github.com/pentaho/mondrian/blob/master/mondrian/src/main/java/mondrian/olap4j/MondrianOlap4jCell.java - the expectation is not consistent with olap4j spec.
spec org.olap4j.Cell.getDoubleValue declares @throws OlapException if this cell does not have a numeric value
see http://www.olap4j.org/api/org/olap4j/Cell.html#getValue()
i think we need threat OlapException raised by Cell.getDoubleValue in same way as NumberFormatException, ie ignore it.
That sounds reasonable to me. I just reviewed your PR and merged with the master. I'll start the publishing process as soon as possible.
Thanks much for the contribution!