Skip to content

Commit

Permalink
MONDRIAN: Oops!
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 3907]
  • Loading branch information
julianhyde committed Jul 31, 2005
1 parent 3ac8df1 commit 443f7f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/main/mondrian/olap/fun/FunUtil.java
Expand Up @@ -277,16 +277,17 @@ public static Member[] getTupleArg(

/**
* Evaluates and returns the <code>index</code>th argument, which we
* expect to be either a member or a tuple, as a tuple. If the argument
* is a member, converts it into a tuple with one member.
* expect to be either a member or a tuple, as a tuple.
* If the argument is a member, converts it into a tuple with one member.
* If the argument is the null tuple, returns null.
*
* @see #getTupleArg
*
* @param evaluator Evaluation context
* @param args The arguments to the function call
* @param index Ordinal of the argument we are seeking
* @return A tuple, represented as usual by an array of {@link Member}
* objects.
* objects, or null if the tuple is null
*
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is out of
* range
Expand All @@ -297,7 +298,9 @@ public static Member[] getTupleOrMemberArg(
int index) {
Exp arg = args[index];
Object o0 = arg.evaluate(evaluator);
if (o0 instanceof Member[]) {
if (o0 == null) {
return null;
} else if (o0 instanceof Member[]) {
return (Member[]) o0;
} else if (o0 instanceof Member) {
return new Member[] { (Member)o0 };
Expand Down
4 changes: 4 additions & 0 deletions src/main/mondrian/olap/fun/RankFunDef.java
Expand Up @@ -30,6 +30,10 @@ public RankFunDef() {
public Object evaluate(Evaluator evaluator, Exp[] args) {
// get tuple
Member[] tuple = getTupleOrMemberArg(evaluator, args, 0);
if (tuple == null) {
// Tuple is null.
return null;
}
for (int i = 0; i < tuple.length; i++) {
// Rank of a null member or partially null tuple returns null.
Member member = tuple[i];
Expand Down

0 comments on commit 443f7f3

Please sign in to comment.