Skip to content

Commit

Permalink
MONDRIAN: Fix bug 1784617, "Using StrToTuple() in schema errors out".
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 9898]
  • Loading branch information
julianhyde committed Sep 21, 2007
1 parent 234bc7d commit ecfe757
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/mondrian/olap/fun/StrToTupleFunDef.java
Expand Up @@ -112,7 +112,7 @@ public Exp createCall(Validator validator, Exp[] args) {
DimensionExpr dimensionExpr = (DimensionExpr) arg;
Dimension dimension = dimensionExpr.getDimension();
args[i] = new HierarchyExpr(dimension.getHierarchy());
} else if (arg instanceof Hierarchy) {
} else if (arg instanceof HierarchyExpr) {
// nothing
} else {
throw MondrianResource.instance().MdxFuncNotHier.ex(
Expand Down Expand Up @@ -175,7 +175,8 @@ public FunDef resolve(
}
for (int i = 1; i < args.length; i++) {
Exp exp = args[i];
if (!(exp instanceof DimensionExpr)) {
if (!(exp instanceof DimensionExpr
|| exp instanceof HierarchyExpr)) {
return null;
}
}
Expand Down
36 changes: 35 additions & 1 deletion testsrc/main/mondrian/test/TestCalculatedMembers.java
Expand Up @@ -958,6 +958,40 @@ public void testCalcMemberCustomFormatterInSchemaNegative() {
+ "from [Sales]",
"Failed to load formatter class 'mondrian.test.NonExistentCellFormatter' for member '[Measures].[Profit Formatted]'.");
}

/**
* Testcase for bug 1784617, "Using StrToTuple() in schema errors out".
*/
public void testStrToSetInCubeCalcMember() {

// calc member defined in schema
String cubeName = "Sales";
TestContext testContext =
TestContext.createSubstitutingCube(
cubeName,
null,
"<CalculatedMember\n" +
" name=\"My Tuple\"\n" +
" dimension=\"Measures\"\n" +
" visible=\"false\"\n" +
" formula=\"StrToTuple('([Gender].[M], [Marital Status].[S])', [Gender], [Marital Status])\"/>\n");
String desiredResult =
fold("Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Measures].[My Tuple]}\n" +
"Row #0: 68,755\n");
testContext.assertQueryReturns(
"select {[Measures].[My Tuple]} on 0 from [Sales]",
desiredResult);

// same result if calc member is defined in query
TestContext.instance().assertQueryReturns(
"with member [Measures].[My Tuple] as\n"
+ " 'StrToTuple(\"([Gender].[M], [Marital Status].[S])\", [Gender], [Marital Status])'\n"
+ "select {[Measures].[My Tuple]} on 0 from [Sales]",
desiredResult);
}
}

// End CalculatedMembersTestCase.java
// End TestCalculatedMembers.java

0 comments on commit ecfe757

Please sign in to comment.