Skip to content

Commit

Permalink
MONDRIAN: enhance TupleReader to handle Crossjoins with ALL member
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 4457]
  • Loading branch information
Andreas Voss committed Nov 22, 2005
1 parent 93460ed commit 5c2fe8e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
2 changes: 0 additions & 2 deletions src/main/mondrian/rolap/RolapNativeSet.java
Expand Up @@ -275,8 +275,6 @@ else if (!level.equals(m.getLevel()))
}
if (!isSimpleLevel(level))
return null;
if (level.isAll())
return null;
RolapMember[] members = new RolapMember[args.length];
System.arraycopy(args, 0, members, 0, args.length);
return new EnumCrossJoinArg(level, members, strict);
Expand Down
5 changes: 1 addition & 4 deletions src/main/mondrian/rolap/SqlTupleReader.java
Expand Up @@ -21,9 +21,9 @@
import mondrian.olap.MondrianProperties;
import mondrian.olap.Util;
import mondrian.resource.MondrianResource;
import mondrian.rolap.sql.TupleConstraint;
import mondrian.rolap.sql.MemberChildrenConstraint;
import mondrian.rolap.sql.SqlQuery;
import mondrian.rolap.sql.TupleConstraint;

/**
* reads the members of a single level (level.members) or of multiple levels (crossjoin).
Expand Down Expand Up @@ -359,11 +359,8 @@ String makeLevelMembersSql(Connection jdbcConnection) {
*
* <li><code>"init", "bar"</code> are member properties.</li>
* </ul>
*
* @pre !level.isAll()
*/
void addLevelMemberSql(SqlQuery sqlQuery, RolapLevel level) {
Util.assertPrecondition(!level.isAll());
RolapHierarchy hierarchy = (RolapHierarchy) level.getHierarchy();

RolapLevel[] levels = (RolapLevel[]) hierarchy.getLevels();
Expand Down
37 changes: 27 additions & 10 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -46,6 +46,29 @@ public class NonEmptyTest extends FoodMartTestCase {
private static Logger logger = Logger.getLogger(NonEmptyTest.class);
SqlConstraintFactory scf = SqlConstraintFactory.instance();

/**
* getMembersInLevel where Level = (All)
*/
public void testAllLevelMembers() {
checkNative(14, 14, "select {[Measures].[Store Sales]} ON COLUMNS, "
+ "NON EMPTY Crossjoin([Product].[(All)].Members, [Promotion Media].[All Media].Children) ON ROWS "
+ "from [Sales]");

}

/**
* enum sets {} containing ALL
*/
public void testCjDescendantsEnumAllOnly() {
checkNative(9, 9,
"select {[Measures].[Unit Sales]} ON COLUMNS, "
+ "NON EMPTY Crossjoin("
+ " Descendants([Customers].[All Customers].[USA], [Customers].[City]), "
+ " {[Product].[All Products]}) ON ROWS "
+ "from [Sales] "
+ "where ([Promotions].[All Promotions].[Bag Stuffers])");
}

/**
* checks that crossjoin returns a modifiable copy from cache
* because its modified during sort
Expand Down Expand Up @@ -156,16 +179,9 @@ public void testCjEnumEnum() {
+ "from [Sales] ");
}

/** Enumerated sets containing ALL will not be computed natively */
public void testCjDescendantsEnumAllOnly() {
checkNotNative(9, "select {[Measures].[Unit Sales]} ON COLUMNS, " + "NON EMPTY Crossjoin("
+ " Descendants([Customers].[All Customers].[USA], [Customers].[City]), "
+ " {[Product].[All Products]}) ON ROWS " + "from [Sales] "
+ "where ([Promotions].[All Promotions].[Bag Stuffers])");
}

/**
* Enumerated sets containing ALL will not be computed natively
* enum sets {} containing members from different levels can not be computed
* natively currently.
*/
public void testCjDescendantsEnumAll() {
checkNotNative(
Expand All @@ -174,7 +190,8 @@ public void testCjDescendantsEnumAll() {
+ "NON EMPTY Crossjoin("
+ " Descendants([Customers].[All Customers].[USA], [Customers].[City]), "
+ " {[Product].[All Products], [Product].[All Products].[Drink].[Dairy]}) ON ROWS "
+ "from [Sales] " + "where ([Promotions].[All Promotions].[Bag Stuffers])");
+ "from [Sales] "
+ "where ([Promotions].[All Promotions].[Bag Stuffers])");
}

public void testCjDescendantsEnum() {
Expand Down

0 comments on commit 5c2fe8e

Please sign in to comment.