*/
public Member executeSingletonAxis(String expression) {
final String cubeName = getDefaultCubeName();
Result result = executeQuery(
"select {" + expression + "} on columns from " + cubeName);
Axis axis = result.getAxes()[0];
switch (axis.getPositions().size()) {
case 0:
// The mdx "{...}" operator eliminates null members (that is,
// members for which member.isNull() is true). So if "expression"
// yielded just the null member, the array will be empty.
return null;
case 1:
// Java nulls should never happen during expression evaluation.
Position position = axis.getPositions().get(0);
Util.assertTrue(position.size() == 1);
Member member = position.get(0);
Util.assertTrue(member != null);
return member;
default:
throw Util.newInternal(
"expression " + expression
+ " yielded " + axis.getPositions().size() + " positions");
}
}