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

Julian Hyde jhyde at pentaho.org
Tue Feb 5 03:25:12 EST 2008


Your suggested fix happens to work, but it's wrong. What do think the right
answer is? (Not just what happens to work.)


  _____  

From: mondrian-bounces at pentaho.org [mailto:mondrian-bounces at pentaho.org] On
Behalf Of Harun Pathan
Sent: Monday, February 04, 2008 11:33 PM
To: mondrian at pentaho.org
Subject: [Mondrian] When iif has tupletypes with unequal lengths
asarguments, we get an exception


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

WITH 
MEMBER [Gender].agg
AS 'IIF(1=1, 
        ([Store].[All Stores],[Gender].[All Gender]),
        ([Store].[All Stores],[Gender].[All Gender],measures.[unit sales])
)', SOLVE_ORDER = 4
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/ff61f725/attachment.html 


More information about the Mondrian mailing list