Skip to content

Commit

Permalink
mondrian: another tweak on the NECJ slicer dependency fix. Added more…
Browse files Browse the repository at this point in the history
… tests for non-calculated slicer members.

[git-p4: depot-paths = "//open/mondrian/": change = 9278]
  • Loading branch information
Rushan Chen committed May 17, 2007
1 parent 748805a commit 07407b2
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 14 deletions.
20 changes: 18 additions & 2 deletions src/main/mondrian/olap/fun/CrossJoinFunDef.java
Expand Up @@ -2449,14 +2449,30 @@ protected List nonEmptyListNEW(
if (em.isMeasure()) {
continue;
}
if (em.isCalculated() && !isSlicerMember) {

//
// The unconstrained members need to be replaced by the "All"
// member based on its usage and property. This is currently
// also the behavior of native cross join evaluation. See
// SqlConstraintUtils.addContextConstraint()
//
// on slicer? | calculated? | replace with All?
// -----------------------------------------------
// Y | Y | Y always
// Y | N | N
// N | Y | N
// N | N | Y if not "All"
// -----------------------------------------------
//
if (( isSlicerMember && !em.isCalculated()) ||
(!isSlicerMember && em.isCalculated())) {
continue;
}

// If the member is not the All member;
// or if it is a slicer member,
// replace with the "all" member.
if (!em.isAll() || isSlicerMember) {
if (isSlicerMember || !em.isAll()) {
Hierarchy h = em.getHierarchy();
Member[] rootMembers = schemaReader.getHierarchyRootMembers(h);
if (h.hasAll()) {
Expand Down
112 changes: 106 additions & 6 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -1725,7 +1725,11 @@ public void testCalculatedSlicerMember() {
// Otherwise, if they are not ignored, stack over flow will occur
// because emptiness check depends on a calculated slicer member
// which references the non-empty set being computed.
executeQuery(
//
// Bcause native evaluation already ignores calculated members on
// the slicer, both native and non-native evaluation should return
// the same result.
checkNative(20, 1,
"With " +
"Set BM_PRODUCT as '{[Product].[All Products].[Drink]}' " +
"Set BM_EDU as '[Education Level].[Education Level].Members' " +
Expand All @@ -1743,17 +1747,113 @@ public void testCalculatedSlicerMember() {
);
}

public void testDependentSlicerMember() {
// Note: this test produces different result under native or nonnative
// evaluation. To be fixed.
executeQuery("with set [p] as '[Product].[Product Family].members' " +
public void testIndependentSlicerMemberNonNative() {
String query =
"with set [p] as '[Product].[Product Family].members' " +
"set [s] as '[Store].[Store Country].members' " +
"set [ne] as 'nonemptycrossjoin([p],[s])' " +
"set [nep] as 'Generate([ne],{[Product].CurrentMember})' " +
"select [nep] on columns from sales " +
"where ([Store].[Store Country].[Mexico])");
"where ([Store].[Store Country].[Mexico])";

String resultNonNative =
"Axis #0:\n" +
"{[Store].[All Stores].[Mexico]}\n" +
"Axis #1:\n" +
"{[Product].[All Products].[Drink]}\n" +
"{[Product].[All Products].[Food]}\n" +
"{[Product].[All Products].[Non-Consumable]}\n" +
"Row #0: \n" +
"Row #0: \n" +
"Row #0: \n";

boolean origNativeCJ =
MondrianProperties.instance().EnableNativeCrossJoin.get();
MondrianProperties.instance().EnableNativeCrossJoin.set(false);

Connection conn = getTestContext().getFoodMartConnection(false);
TestContext context = getTestContext(conn);
context.assertQueryReturns(query, resultNonNative);

MondrianProperties.instance().EnableNativeCrossJoin.set(origNativeCJ);
}

public void testIndependentSlicerMemberNative() {
// Currently this behaves differently from non-native evaluation.
String query =
"with set [p] as '[Product].[Product Family].members' " +
"set [s] as '[Store].[Store Country].members' " +
"set [ne] as 'nonemptycrossjoin([p],[s])' " +
"set [nep] as 'Generate([ne],{[Product].CurrentMember})' " +
"select [nep] on columns from sales " +
"where ([Store].[Store Country].[Mexico])";

String resultNative =
"Axis #0:\n" +
"{[Store].[All Stores].[Mexico]}\n" +
"Axis #1:\n";

boolean origNativeCJ =
MondrianProperties.instance().EnableNativeCrossJoin.get();
MondrianProperties.instance().EnableNativeCrossJoin.set(true);

Connection conn = getTestContext().getFoodMartConnection(false);
TestContext context = getTestContext(conn);
context.assertQueryReturns(query, resultNative);

MondrianProperties.instance().EnableNativeCrossJoin.set(origNativeCJ);
}

public void testDependentSlicerMemberNonNative() {
String query =
"with set [p] as '[Product].[Product Family].members' " +
"set [s] as '[Store].[Store Country].members' " +
"set [ne] as 'nonemptycrossjoin([p],[s])' " +
"set [nep] as 'Generate([ne],{[Product].CurrentMember})' " +
"select [nep] on columns from sales " +
"where ([Time].[1998])";

String resultNonNative =
"Axis #0:\n" +
"{[Time].[1998]}\n" +
"Axis #1:\n";

boolean origNativeCJ =
MondrianProperties.instance().EnableNativeCrossJoin.get();
MondrianProperties.instance().EnableNativeCrossJoin.set(false);

Connection conn = getTestContext().getFoodMartConnection(false);
TestContext context = getTestContext(conn);
context.assertQueryReturns(query, resultNonNative);

MondrianProperties.instance().EnableNativeCrossJoin.set(origNativeCJ);
}

public void testDependentSlicerMemberNative() {
String query =
"with set [p] as '[Product].[Product Family].members' " +
"set [s] as '[Store].[Store Country].members' " +
"set [ne] as 'nonemptycrossjoin([p],[s])' " +
"set [nep] as 'Generate([ne],{[Product].CurrentMember})' " +
"select [nep] on columns from sales " +
"where ([Time].[1998])";

String resultNative =
"Axis #0:\n" +
"{[Time].[1998]}\n" +
"Axis #1:\n";

boolean origNativeCJ =
MondrianProperties.instance().EnableNativeCrossJoin.get();
MondrianProperties.instance().EnableNativeCrossJoin.set(true);

Connection conn = getTestContext().getFoodMartConnection(false);
TestContext context = getTestContext(conn);
context.assertQueryReturns(query, resultNative);

MondrianProperties.instance().EnableNativeCrossJoin.set(origNativeCJ);
}

/**
* make sure the following is not run natively
*/
Expand Down
10 changes: 4 additions & 6 deletions testsrc/main/mondrian/rolap/SharedDimensionTest.java
Expand Up @@ -111,7 +111,7 @@ public class SharedDimensionTest extends FoodMartTestCase {
"set [*BASE_MEMBERS_Store Type] as '[Store Type].[Store Type].Members'\n" +
"set [*BASE_MEMBERS_Store] as '[Store].[Store State].Members'\n" +
"select [*BASE_MEMBERS_Measures] ON COLUMNS,\n" +
"Generate([*NATIVE_CJ_SET], {[Store Type].CurrentMember}) on rows from [Store]";
"Non Empty Generate([*NATIVE_CJ_SET], {[Store Type].CurrentMember}) on rows from [Store]";

public static String queryNECJMemberList =
"select {[Measures].[Employee Store Sales]} on columns,\n" +
Expand Down Expand Up @@ -244,16 +244,14 @@ public class SharedDimensionTest extends FoodMartTestCase {
"Axis #2:\n" +
"{[Store Type].[All Store Types].[Deluxe Supermarket]}\n" +
"{[Store Type].[All Store Types].[Gourmet Supermarket]}\n" +
"{[Store Type].[All Store Types].[HeadQuarters]}\n" +
"{[Store Type].[All Store Types].[Mid-Size Grocery]}\n" +
"{[Store Type].[All Store Types].[Small Grocery]}\n" +
"{[Store Type].[All Store Types].[Supermarket]}\n" +
"Row #0: 146,045\n" +
"Row #1: 47,447\n" +
"Row #2: \n" +
"Row #3: 109,343\n" +
"Row #4: 75,281\n" +
"Row #5: 193,480\n";
"Row #2: 109,343\n" +
"Row #3: 75,281\n" +
"Row #4: 193,480\n";

public static String resultNECJMemberList =
"Axis #0:\n" +
Expand Down

0 comments on commit 07407b2

Please sign in to comment.