Skip to content

Commit

Permalink
MONDRIAN: The second half of the fix for MONDRIAN-506. This allows qu…
Browse files Browse the repository at this point in the history
…eries with Descendants using an integer value for the second argument to be natively evaluated. The first part of this defect was fixed in 12424, which allowed redundant set braces to be used with native eval.

[git-p4: depot-paths = "//open/mondrian/": change = 13071]
  • Loading branch information
Matt Campbell authored and Matt Campbell committed Sep 29, 2009
1 parent eee6414 commit f2629ca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/main/mondrian/rolap/RolapNativeSet.java
Expand Up @@ -627,10 +627,22 @@ protected CrossJoinArg checkDescendants(
if (member.isCalculated()) {
return null;
}
if (!(args[1] instanceof LevelExpr)) {
RolapLevel level = null;
if ((args[1] instanceof LevelExpr)) {
level = (RolapLevel) ((LevelExpr) args[1]).getLevel();
} else if (args[1] instanceof Literal) {
RolapLevel[] levels = (RolapLevel[])
member.getHierarchy().getLevels();
int currentDepth = member.getDepth();
Literal descendantsDepth = (Literal)args[1];
int newDepth = currentDepth + descendantsDepth.getIntValue();
if (newDepth < levels.length) {
level = levels[newDepth];
}
} else {
return null;
}
RolapLevel level = (RolapLevel) ((LevelExpr) args[1]).getLevel();

if (!isSimpleLevel(level)) {
return null;
}
Expand Down
14 changes: 14 additions & 0 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -1592,6 +1592,20 @@ public void testCjMembersDescendants() {
+ " [Time].[1997].[Q1].[1])");
}

// testcase for bug MONDRIAN-506
public void testCjMembersDescendantsWithNumericArgument() {
checkNative(
67,
67,
"select {[Measures].[Store Sales]} on columns,"
+ " NON EMPTY Crossjoin("
+ " {[Product].[Product Name].Members},"
+ " {Descendants([Customers].[All Customers].[USA].[CA], 2)}) ON rows "
+ " from [Sales] where ("
+ " [Store].[All Stores].[USA].[CA].[San Francisco].[Store 14],"
+ " [Time].[1997].[Q1].[1])");
}

public void testCjChildrenMembers() {
checkNative(
67, 67, "select {[Measures].[Store Sales]} on columns,"
Expand Down

0 comments on commit f2629ca

Please sign in to comment.