Skip to content

Commit

Permalink
MONDRIAN: add a test case for ExoandNonNative when input is
Browse files Browse the repository at this point in the history
tuple list.

[git-p4: depot-paths = "//open/mondrian/": change = 11201]
  • Loading branch information
Rushan Chen committed Jun 19, 2008
1 parent de162be commit a1cd52e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 12 deletions.
11 changes: 4 additions & 7 deletions src/main/mondrian/rolap/RolapNativeSet.java
Expand Up @@ -736,12 +736,10 @@ protected CrossJoinArg[] checkCrossJoin(
// MemberListCrossJoinArg.
// If either the inputs can be natively evaluated, or the result list
CrossJoinArg[] arg0 = checkCrossJoinArg(evaluator, args[0]);
ListCalc listCalc0;
List<RolapMember> list0 = null;
if (arg0 == null) {
if (MondrianProperties.instance().ExpandNonNative.get()) {
listCalc0 = compiler.compileList(args[0]);
list0 = Util.cast(listCalc0.evaluateList(evaluator));
ListCalc listCalc0 = compiler.compileList(args[0]);
List<RolapMember> list0 = Util.cast(listCalc0.evaluateList(evaluator));
// Prevent the case when the second argument size is too large
if (list0 != null) {
Util.checkCJResultLimit(list0.size());
Expand All @@ -761,10 +759,9 @@ protected CrossJoinArg[] checkCrossJoin(
CrossJoinArg[] arg1 = checkCrossJoinArg(evaluator, args[1]);
if (arg1 == null) {
if (MondrianProperties.instance().ExpandNonNative.get()) {
MemberListCalc listCalc1 =
ListCalc listCalc1 =
(MemberListCalc) compiler.compileList(args[1]);
List<RolapMember> list1 =
Util.cast(listCalc1.evaluateMemberList(evaluator));
List<RolapMember> list1 = Util.cast(listCalc1.evaluateList(evaluator));
// Prevent the case when the second argument size is too large
if (list1 != null) {
Util.checkCJResultLimit(list1.size());
Expand Down
40 changes: 35 additions & 5 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -858,7 +858,37 @@ public void testExpandDifferentLevels() {
* Verify that native evaluation is turned off for tuple inputs, even if
* ExpandNonNative is set.
*/
public void testExpandTupleInputs() {
public void testExpandTupleInputs1() {
String query =
"with " +
"set [Tuple Set] as {([Store Type].[All Store Types].[HeadQuarters], [Product].[All Products].[Drink]), ([Store Type].[All Store Types].[Supermarket], [Product].[All Products].[Food])} " +
"set [Filtered Tuple Set] as Filter([Tuple Set], 1=1) " +
"set [NECJ] as NonEmptyCrossJoin([Store].Children, [Filtered Tuple Set]) " +
"select [NECJ] on rows from [Sales]";

String result =
"Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Store].[All Stores].[USA], [Store Type].[All Store Types].[Supermarket], [Product].[All Products].[Food]}\n" +
"Row #0: 108,188\n";

boolean origExpandNonNative =
MondrianProperties.instance().ExpandNonNative.get();
MondrianProperties.instance().ExpandNonNative.set(true);

try {
checkNotNative(1, query, fold(result));
} finally {
MondrianProperties.instance().ExpandNonNative.set(origExpandNonNative);
}
}

/**
* Verify that native evaluation is turned off for tuple inputs, even if
* ExpandNonNative is set.
*/
public void testExpandTupleInputs2() {
String query =
"with " +
"set [Tuple Set] as {([Store Type].[All Store Types].[HeadQuarters], [Product].[All Products].[Drink]), ([Store Type].[All Store Types].[Supermarket], [Product].[All Products].[Food])} " +
Expand Down Expand Up @@ -3274,7 +3304,7 @@ public void excutingSql(TupleEvent e) {
String nonNativeResult = toString(result);
if (!nonNativeResult.equals(expectedResult)) {
TestContext.assertEqualsVerbose(
nonNativeResult, expectedResult, false,
expectedResult, nonNativeResult, false,
"Non Native implementation returned different result than " +
"expected; MDX=" + mdx);
}
Expand Down Expand Up @@ -3377,16 +3407,16 @@ private void checkNative(

if (expectedResult != null) {
TestContext.assertEqualsVerbose(
nativeResult, expectedResult, false,
expectedResult, nativeResult, false,
"Native implementation returned different result than expected; MDX=" + mdx);
TestContext.assertEqualsVerbose(
interpretedResult, expectedResult, false,
expectedResult, interpretedResult, false,
"Interpreter implementation returned different result than expected; MDX=" + mdx);
}

if (!nativeResult.equals(interpretedResult)) {
TestContext.assertEqualsVerbose(
nativeResult, interpretedResult, false,
interpretedResult, nativeResult, false,
"Native implementation returned different result than interpreter; MDX=" + mdx);
}

Expand Down

0 comments on commit a1cd52e

Please sign in to comment.