Skip to content

Commit

Permalink
MONDRIAN: Fix bug 2150537, "error deducing type of Ytd/Qtd/Mtd functi…
Browse files Browse the repository at this point in the history
…ons within Generate".

[git-p4: depot-paths = "//open/mondrian/": change = 11679]
  • Loading branch information
julianhyde committed Oct 7, 2008
1 parent 4199a92 commit 0bd34d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/mondrian/olap/fun/XtdFunDef.java
Expand Up @@ -78,8 +78,7 @@ public Type getResultType(Validator validator, Exp[] args) {
return new SetType(MemberType.forHierarchy(hierarchy));
}
final Type type = args[0].getType();
if (type.getHierarchy().getDimension()
.getDimensionType() !=
if (type.getDimension().getDimensionType() !=
DimensionType.TimeDimension) {
throw MondrianResource.instance().TimeArgNeeded.ex(getName());
}
Expand Down Expand Up @@ -145,7 +144,7 @@ public ResolverImpl(
protected FunDef createFunDef(Exp[] args, FunDef dummyFunDef) {
return new XtdFunDef(dummyFunDef, levelType);
}
};
}
}

// End XtdFunDef.java
39 changes: 39 additions & 0 deletions testsrc/main/mondrian/olap/fun/FunctionTest.java
Expand Up @@ -6483,6 +6483,45 @@ public void testYtd() {
getTestContext().assertSetExprDependsOn("Ytd([Time].[1997].[Q2])", "{}");
}

/**
* Testcase for
* <a href="https://sourceforge.net/tracker/?func=detail&atid=414613&aid=2150537&group_id=35302">
* bug 2150537, "error deducing type of Ytd/Qtd/Mtd functions within
* Generate"</a>.
*/
public void testGeneratePlusXtd() {
assertAxisReturns(
"generate(\n"
+ " {[Time].[1997].[Q1].[2], [Time].[1997].[Q3].[7]},\n"
+ " {Ytd( [Time].currentMember)})",
fold("[Time].[1997].[Q1].[1]\n" +
"[Time].[1997].[Q1].[2]\n" +
"[Time].[1997].[Q1].[3]\n" +
"[Time].[1997].[Q2].[4]\n" +
"[Time].[1997].[Q2].[5]\n" +
"[Time].[1997].[Q2].[6]\n" +
"[Time].[1997].[Q3].[7]"));
assertAxisReturns(
"generate(\n"
+ " {[Time].[1997].[Q1].[2], [Time].[1997].[Q3].[7]},\n"
+ " {Ytd( [Time].currentMember)}, ALL)",
fold("[Time].[1997].[Q1].[1]\n" +
"[Time].[1997].[Q1].[2]\n" +
"[Time].[1997].[Q1].[1]\n" +
"[Time].[1997].[Q1].[2]\n" +
"[Time].[1997].[Q1].[3]\n" +
"[Time].[1997].[Q2].[4]\n" +
"[Time].[1997].[Q2].[5]\n" +
"[Time].[1997].[Q2].[6]\n" +
"[Time].[1997].[Q3].[7]"));
assertExprReturns(
"count(generate({[Time].[1997].[Q4].[11]}, {Qtd( [Time].currentMember)}))",
2, 0);
assertExprReturns(
"count(generate({[Time].[1997].[Q4].[11]}, {Mtd( [Time].currentMember)}))",
1, 0);
}

public void testQtd() {
// zero args
assertQueryReturns(
Expand Down

0 comments on commit 0bd34d7

Please sign in to comment.