Skip to content

Commit

Permalink
MONDRIAN [MONDRIAN-897] Fixes an issue with named sets composed of an…
Browse files Browse the repository at this point in the history
…other named set which was causing a ClassCastException when optimizing. Patch contributed by Joe Barnett.

[git-p4: depot-paths = "//open/mondrian/": change = 14415]
  • Loading branch information
lucboudreau committed Jun 30, 2011
1 parent efe8116 commit b791fd3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/sql/CrossJoinArgFactory.java
Expand Up @@ -931,7 +931,7 @@ private boolean isCheapSet(Exp exp) {
Arrays.asList("LastChild", "FirstChild", "Lag");

private boolean allArgsCheapToExpand(Exp exp) {
if (exp instanceof NamedSetExpr) {
while (exp instanceof NamedSetExpr) {
exp = ((NamedSetExpr) exp).getNamedSet().getExp();
}
for (Exp arg : ((ResolvedFunCall) exp).getArgs()) {
Expand Down
30 changes: 30 additions & 0 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -4813,6 +4813,36 @@ public void testFilterChildlessSnowflakeMembers() {
}
}
}

/**
* Test case for <a href="http://jira.pentaho.com/browse/MONDRIAN-897">
* MONDRIAN-897, "ClassCastException in
* CrossJoinArgFactory.allArgsCheapToExpand when defining a NamedSet as
* another NamedSet"</a>.
*/
public void testBugMondrian897DoubleNamedSetDefinitions() {
TestContext ctx = getTestContext();
ctx.assertQueryReturns(
"WITH SET [CustomerSet] as {[Customers].[Canada].[BC].[Burnaby].[Alexandra Wellington], [Customers].[USA].[WA].[Tacoma].[Eric Coleman]} "
+ "SET [InterestingCustomers] as [CustomerSet] "
+ "SET [TimeRange] as {[Time].[1998].[Q1], [Time].[1998].[Q2]} "
+ "SELECT {[Measures].[Store Sales]} ON COLUMNS, "
+ "CrossJoin([InterestingCustomers], [TimeRange]) ON ROWS "
+ "FROM [Sales]",
"Axis #0:\n"
+ "{}\n"
+ "Axis #1:\n"
+ "{[Measures].[Store Sales]}\n"
+ "Axis #2:\n"
+ "{[Customers].[Canada].[BC].[Burnaby].[Alexandra Wellington], [Time].[1998].[Q1]}\n"
+ "{[Customers].[Canada].[BC].[Burnaby].[Alexandra Wellington], [Time].[1998].[Q2]}\n"
+ "{[Customers].[USA].[WA].[Tacoma].[Eric Coleman], [Time].[1998].[Q1]}\n"
+ "{[Customers].[USA].[WA].[Tacoma].[Eric Coleman], [Time].[1998].[Q2]}\n"
+ "Row #0: \n"
+ "Row #1: \n"
+ "Row #2: \n"
+ "Row #3: \n");
}
}

// End NonEmptyTest.java

0 comments on commit b791fd3

Please sign in to comment.