[Mondrian] When iif has tupletypes with unequal lengths as arguments, we get an exception

Harun Pathan harunap at gmail.com
Tue Feb 5 02:32:56 EST 2008

When we run this mdx we get an error stacktrace for which is as below.

MEMBER [Gender].agg
AS 'IIF(1=1,
        ([Store].[All Stores],[Gender].[All Gender]),
        ([Store].[All Stores],[Gender].[All Gender],measures.[unit sales])
SELECT {[Measures].[unit sales]} ON 0,
{{[Gender].[Gender].MEMBERS},{([Gender].agg)}} on 1 FROM sales

Caused by: mondrian.olap.MondrianException: Mondrian Error:Internal
error: could not derive type
at mondrian.resource.MondrianResource$_Def0.ex(Mondri anResource.java:777)
at mondrian.olap.Util.newInternal(Util.java:1333)
at mondrian.olap.fun.FunDefBase.createCall(FunDefBase .java:245)
at mondrian.mdx.UnresolvedFunCall.accept(UnresolvedFu nCall.java:101)
at mondrian.olap.Query$StackValidator.validate(Query. java:1229)
at mondrian.olap.Formula.accept(Formula.java:131)
at mondrian.olap.Query$StackValidator.validate(Query. java:1304)
at mondrian.olap.Query.resolve(Query.java:571)
at mondrian.olap.Query.resolve(Query.java:433)
at mondrian.olap.Query.<init>(Query.java:217)
at mondrian.olap.Query.<init>(Query.java:177)
at mondrian.olap.Parser.makeQuery(Parser.java:850)
at mondrian.olap.CUP$Parser$actions.CUP$Parser$do_act ion(Parser.java:1683)
at mondrian.olap.Parser.do_action(Parser.java:684)
at java_cup.runtime.lr_parser.parse(lr_parser.java:56 9)
at mondrian.olap.Parser.parseInternal(Parser.java:754 )

When iif function is resolved, it tried to get common result type between
its arguments.
It return null if the number of element types in both are unequal.Instead we
need to return a ScalarType.

Following is the code change in TupleType

TupleType that = (TupleType) type;
if (this.elementTypes.length !=
    that.elementTypes.length) {
    return new ScalarType();   //earlier it was returning null

Can we go ahead and check this in?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20080205/a195e163/attachment.html 

More information about the Mondrian mailing list