Affects Version/s: None
Fix Version/s: Backlog
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:
> /, *
> +, -
> <>, >=, =, <=, >, <
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.)