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

AS operator has lower precedence than required by MDX specification

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Medium Medium
    • Resolution: Unresolved
    • 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.

      Description

      The AS operator (which creates named sets within expressions) has the wrong precedence.

      For example, given

      select [Time].Children * [Gender].Children as t on 0 from Sales

      should according to the MDX spec be equivalent to

      select [Time].Children * ([Gender].Children as t) on 0 from Sales

      but in current Mondrian it is equivalent to

      select ([Time].Children * [Gender].Children) as t on 0 from Sales

      In other words, 'AS' has lower precedence than '*' but should have higher precedence.

      From "Operators (MDX Syntax)" http://msdn.microsoft.com/en-us/library/ms144825.aspx :

      > The following list shows operator precedence, from highest to lowest.
      > Operators in the same line are equal in precedence, and are
      > evaluated from left to right unless otherwise forced by parenthesis:
      >
      > IS
      > AS
      > DISTINCT
      > :
      > ^
      > /, *
      > +, -
      > EXISTING
      > <>, >=, =, <=, >, <
      > NOT
      > AND
      > XOR
      > OR

      The low precedence of AS is necessary because AS in the CAST operator has low precedence. Otherwise

      CAST(a AND b AS string)

      would be parsed as

      CAST(a AND (b AS string))

      which is silly. It's difficult to give AS different precedences in different contexts, so we chose to favor CAST. If the precedence rules don't suit, you can add parentheses.

      For more examples, search for this bug number in Mondrian source code and test suite. (Bug.BugMondrianXxxFixed.)

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Julian Hyde
            Reporter:
            Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: