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

Using the generate command, cast and calculated measures causes ClassCastException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Severe Severe
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • 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.
    • QA Validation Status:
      Validated by QA
    • CI Build:
      Oct 6, 2011 9:27:15 PM bi-server-ee-MON33.zip(#60)

      Description

      Using the following sample:

      with
      member [Measures].[Tom1] as '[Measures].[Quantity]+[Measures].[Sales]'

      set spark1 as '([Time].[2005].[QTR1].[Jan].Lag(13.0) : [Time].[2005].[QTR1].[Jan].Lag(0.0))'
        member [Time].[Past 13 weeks] as 'Generate([spark1], CAST(([Measures].CurrentMember + 0.0) AS String), ", ")'
      select {[Time].[Past 13 weeks]} ON COLUMNS,
        {[Measures].[Quantity], [Measures].[Tom1]} ON ROWS
      from [SteelWheelsSales]


      The Tom1 Measure throws a ClassCastException when you use it, but removing the calculation from the calculated member(just referencing a Measure) it suddenly starts working.

      Caused by: mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while executing query [with member [Measures].[Tom1] as '([Measures].[Quantity] / [Measures].[Sales])'
        set spark1 as '([Time].[2005].[QTR1].[Jan].Lag(13.0) : [Time].[2005].[QTR1].[Jan].Lag(0.0))'
        member [Time].[Past 13 weeks] as 'Generate([spark1], CAST(([Measures].CurrentMember + 0.0) AS String), ", ")'
      select {[Time].[Past 13 weeks]} ON COLUMNS,
        {[Measures].[Quantity], [Measures].[Tom1]} ON ROWS
      from [SteelWheelsSales]
      ]
              at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:826)
              at mondrian.olap.Util.newInternal(Util.java:1490)
              at mondrian.olap.Util.newError(Util.java:1506)
              at mondrian.rolap.RolapConnection.execute(RolapConnection.java:622)
              at com.tonbeller.jpivot.mondrian.MondrianModel.getResult(MondrianModel.java:279)
              ... 70 more
      Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
              at mondrian.calc.impl.GenericCalc.evaluateDouble(GenericCalc.java:73)
              at mondrian.olap.fun.BuiltinFunTable$48$2.evaluateDouble(BuiltinFunTable.java:1522)
              at mondrian.calc.impl.AbstractDoubleCalc.evaluate(AbstractDoubleCalc.java:45)
              at mondrian.rolap.RolapEvaluator.evaluateCurrent(RolapEvaluator.java:511)
              at mondrian.rolap.RolapResult.executeStripe(RolapResult.java:902)
              at mondrian.rolap.RolapResult.executeStripe(RolapResult.java:1040)
              at mondrian.rolap.RolapResult.executeStripe(RolapResult.java:1040)
              at mondrian.rolap.RolapResult.executeBody(RolapResult.java:798)
              at mondrian.rolap.RolapResult.<init>(RolapResult.java:416)
              at mondrian.rolap.RolapConnection.execute(RolapConnection.java:593)
              ... 71 more

        Activity

        Hide
        Julian Hyde added a comment -
        Fixed in change 13974.

        Tom, your query is wrong. You need to add SOLVE_ORDER to ensure that the [Time].[Past 13 weeks] calc member is evaluated after everything else. As it is written, you apply "/" to a string value. [Measures].[Quantity] is a string value because [Time].[Past 13 weeks] is the current value of the time dimension, so it converts EVERYTHING into a string value.

        I've changed mondrian so that it gives an evaluation error (which an error in that cell) rather than a ClassCastException that aborts the query.
        Show
        Julian Hyde added a comment - Fixed in change 13974. Tom, your query is wrong. You need to add SOLVE_ORDER to ensure that the [Time].[Past 13 weeks] calc member is evaluated after everything else. As it is written, you apply "/" to a string value. [Measures].[Quantity] is a string value because [Time].[Past 13 weeks] is the current value of the time dimension, so it converts EVERYTHING into a string value. I've changed mondrian so that it gives an evaluation error (which an error in that cell) rather than a ClassCastException that aborts the query.
        Hide
        Suhas Gururaja added a comment -
        Tested this issue on CI build dated Oct 6, 2011 9:27:15 PM bi-server-ee-MON33.zip(#60).

        Used the above mentioned query

        with
        member [Measures].[Tom1] as '[Measures].[Quantity]+[Measures].[Sales]'

        set spark1 as '([Time].[2005].[QTR1].[Jan].Lag(13.0) : [Time].[2005].[QTR1].[Jan].Lag(0.0))'
          member [Time].[Past 13 weeks] as 'Generate([spark1], CAST(([Measures].CurrentMember + 0.0) AS String), ", ")'
        select {[Time].[Past 13 weeks]} ON COLUMNS,
          {[Measures].[Quantity], [Measures].[Tom1]} ON ROWS
        from [SteelWheelsSales]

        We didn't get ClassCastException which aborts the query instead we got evaluation warning but query runs successfully.

        2011-10-07 12:16:01,829 DEBUG [mondrian.rolap.RolapCube] RolapCube.getUsages: name=Measures
        2011-10-07 12:16:01,830 DEBUG [mondrian.rolap.RolapCube] RolapCube.getUsages: name=Measures
        2011-10-07 12:16:01,857 WARN [mondrian.olap.ResultBase] Mondrian: exception in executeStripe.
        mondrian.olap.fun.MondrianEvaluationException: Expected value of type NUMERIC; got value '0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0' (STRING)
        at mondrian.olap.fun.FunUtil.newEvalException(FunUtil.java:82)
        at mondrian.rolap.RolapEvaluator.newEvalException(RolapEvaluator.java:999)

        Please find the attached logs. this issue is fixed.
        Show
        Suhas Gururaja added a comment - Tested this issue on CI build dated Oct 6, 2011 9:27:15 PM bi-server-ee-MON33.zip(#60). Used the above mentioned query with member [Measures].[Tom1] as '[Measures].[Quantity]+[Measures].[Sales]' set spark1 as '([Time].[2005].[QTR1].[Jan].Lag(13.0) : [Time].[2005].[QTR1].[Jan].Lag(0.0))'   member [Time].[Past 13 weeks] as 'Generate([spark1], CAST(([Measures].CurrentMember + 0.0) AS String), ", ")' select {[Time].[Past 13 weeks]} ON COLUMNS,   {[Measures].[Quantity], [Measures].[Tom1]} ON ROWS from [SteelWheelsSales] We didn't get ClassCastException which aborts the query instead we got evaluation warning but query runs successfully. 2011-10-07 12:16:01,829 DEBUG [mondrian.rolap.RolapCube] RolapCube.getUsages: name=Measures 2011-10-07 12:16:01,830 DEBUG [mondrian.rolap.RolapCube] RolapCube.getUsages: name=Measures 2011-10-07 12:16:01,857 WARN [mondrian.olap.ResultBase] Mondrian: exception in executeStripe. mondrian.olap.fun.MondrianEvaluationException: Expected value of type NUMERIC; got value '0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0' (STRING) at mondrian.olap.fun.FunUtil.newEvalException(FunUtil.java:82) at mondrian.rolap.RolapEvaluator.newEvalException(RolapEvaluator.java:999) Please find the attached logs. this issue is fixed.

          People

          • Assignee:
            Suhas Gururaja
            Reporter:
            Tom Barber
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: