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

MDX Order function fails when using DateTime expression for ordering

    Details

    • Type: Bug
    • Status: Closed
    • Severity: High
    • Resolution: Fixed
    • Affects Version/s: 3.3.0 GA (4.1.0 GA Suite Release)
    • 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.

      Description

      For example this MDX query on FoodMart fails

      FoodMart fails:
      SELECT

      {[Measures].[Unit Sales]}

      ON COLUMNS,
      Order([Products].Children, Now(), ASC) ON ROWS
      FROM [Sales]

      Found out that the reason for that is that in mondrian/olap/fun/FunUtil.java compareValues method does not handle Date objects as parameters.
      I created the following patch for this method and as a result Order function is working with DateTime expressions.

      — a/src/main/mondrian/olap/fun/FunUtil.java
      +++ b/src/main/mondrian/olap/fun/FunUtil.java
      @@ -936,6 +936,8 @@ public class FunUtil extends Util

      { ((Number) value1).doubleValue()); }

      else if (value0 instanceof OrderKey)

      { return ((OrderKey) value0).compareTo(value1); + }

      else if (value0 instanceof Date)

      { + return ((Date) value0).compareTo((Date) value1); }

      else

      { throw Util.newInternal("cannot compare " + value0); }

        Activity

        Hide
        lboudreau Luc Boudreau added a comment -

        Fixed in revision 14800. See unit test mondrian.olap.fun.FunUtil.testDateParameter().

        Show
        lboudreau Luc Boudreau added a comment - Fixed in revision 14800. See unit test mondrian.olap.fun.FunUtil.testDateParameter().
        Hide
        sgururaja Suhas Gururaja added a comment -

        Tested the issue using the build dated 22 Feb 2012.
        OS: Ubuntu

        In the above mentioned line number two "Order([Products]." is not there in the schema.
        It should be "Order([Product]."

        "SELECT

        {[Measures].[Unit Sales]}

        ON COLUMNS,
        Order([Product].Children, Now(), ASC) ON ROWS
        FROM [Sales] "

        The query got executed in the latest build without any error.
        Same query fails in 4.1.0GA. Please find the attached screen shot.
        This issue is fixed.

        Show
        sgururaja Suhas Gururaja added a comment - Tested the issue using the build dated 22 Feb 2012. OS: Ubuntu In the above mentioned line number two "Order( [Products] ." is not there in the schema. It should be "Order( [Product] ." "SELECT {[Measures].[Unit Sales]} ON COLUMNS, Order( [Product] .Children, Now(), ASC) ON ROWS FROM [Sales] " The query got executed in the latest build without any error. Same query fails in 4.1.0GA. Please find the attached screen shot. This issue is fixed.

          People

          • Assignee:
            sgururaja Suhas Gururaja
            Reporter:
            raimonds.simanovskis Raimonds Simanovskis
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: