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

UDF regression from Mondrian 2.4->3.1.1: UDF expecting List gets anonymous mondrian.rolap.RolapNamedSetEvaluator$1 instead

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Unknown Unknown
    • Resolution: Fixed
    • Affects Version/s: 3.1.1 GA
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I have a UDF that worked in 2.4 but fails in 3.1.1 with a class cast exception. It expects args[0].evaluate(eval) to return a List, but in 3.1.1 it returns an anonymous iterable from mondrian.rolap.RolapNamedSetEvaluator instead, resulting in a class cast exception. This was originally mentioned in MONDRIAN-588, but I should have provided a better reproduction case.

      The following test can be added tpo testsrc/main/mondrian/test/UdfTest to demonstrate the problem on the Reverse function:

          public void testListUdfWithSetArgument() {
              TestContext tc = TestContext.create(
                  null,
                  null,
                  null,
                  null,
                  "<UserDefinedFunction name=\"Reverse\" className=\""
                  + ReverseFunction.class.getName()
                  + "\"/>\n",
                  null);
              tc.assertQueryReturns(
                  "with set [RM] as '[Gender].Members'\n"
                  + "select Reverse([RM]) on 0\n"
                  + "from [Sales]",
                  "Axis #0:\n"
                  + "{}\n"
                  + "Axis #1:\n"
                  + "{[Gender].[All Gender].[M]}\n"
                  + "{[Gender].[All Gender].[F]}\n"
                  + "{[Gender].[All Gender]}\n"
                  + "Row #0: 135,215\n"
                  + "Row #0: 131,558\n"
                  + "Row #0: 266,773\n");
          }

      The resulting error:

      mondrian.olap.MondrianException: Mondrian Error:Internal error: Error while executing query [with set [RM] as '[Gender].Members'
      select Reverse([RM]) ON COLUMNS
      from [Sales]
      ]
      at mondrian.resource.MondrianResource$_Def0.ex(MondrianResource.java:811)
      at mondrian.olap.Util.newInternal(Util.java:1466)
      at mondrian.olap.Util.newError(Util.java:1482)
      at mondrian.rolap.RolapConnection.execute(RolapConnection.java:592)
      at mondrian.test.TestContext.executeQuery(TestContext.java:488)
      at mondrian.test.TestContext.assertQueryReturns(TestContext.java:915)
      at mondrian.test.UdfTest.testListUdfWithSetArgument(UdfTest.java:774)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40)
      Caused by: java.lang.ClassCastException: mondrian.rolap.RolapNamedSetEvaluator$1
      at mondrian.test.UdfTest$ReverseFunction.execute(UdfTest.java:1063)
      at mondrian.olap.fun.UdfResolver$ListCalcImpl.evaluateList(UdfResolver.java:212)
      at mondrian.calc.impl.AbstractListCalc.evaluateMemberList(AbstractListCalc.java:84)
      at mondrian.calc.impl.AbstractExpCompiler$MemberListIterCalc.evaluateMemberIterable(AbstractExpCompiler.java:573)
      at mondrian.calc.impl.AbstractMemberIterCalc.evaluate(AbstractMemberIterCalc.java:52)
      at mondrian.rolap.RolapResult.executeAxis(RolapResult.java:745)
      at mondrian.rolap.RolapResult.evalLoad(RolapResult.java:588)
      at mondrian.rolap.RolapResult.loadMembers(RolapResult.java:554)
      at mondrian.rolap.RolapResult.<init>(RolapResult.java:268)
      at mondrian.rolap.RolapConnection.execute(RolapConnection.java:563)
      ... 19 more

        Activity

        Hide
        Julian Hyde added a comment -
        Fixed in change 12986 (on mondrian-release/3.1 branch). UDF author must now call Argument.evaluateList or Argument.evaluateIter if the argument is an MDX set. It is not safe to call evaluate and cast the result to a List; it might sometimes be an Iterable.
        Show
        Julian Hyde added a comment - Fixed in change 12986 (on mondrian-release/3.1 branch). UDF author must now call Argument.evaluateList or Argument.evaluateIter if the argument is an MDX set. It is not safe to call evaluate and cast the result to a List; it might sometimes be an Iterable.
        Hide
        Golda David added a comment -
        This is fixed.
        Show
        Golda David added a comment - This is fixed.

          People

          • Assignee:
            Golda David
            Reporter:
            Eric McDermid
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: