Skip to content

Commit

Permalink
MONDRIAN: Fix for bug #1955815, Cartesian Join in SQL from MDX agains…
Browse files Browse the repository at this point in the history
…t virtual cube. Don't apply non-empty constraint in SQLTupleReader if base cube is out of sync with context.

[git-p4: depot-paths = "//open/mondrian/": change = 11321]
  • Loading branch information
Will Gorman committed Jul 18, 2008
1 parent c021ebc commit 56261f8
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/mondrian/rolap/SqlTupleReader.java
Expand Up @@ -650,8 +650,12 @@ private String generateSelectForLevels(
}
}

// additional constraints
constraint.addConstraint(sqlQuery, baseCube);
// if we're a virtual cube (baseCube != null), only apply the
// constraint if it maps to the current base cube.
if (baseCube == null ||
constraint.getEvaluator().getMeasureCube().equals(baseCube)) {
constraint.addConstraint(sqlQuery, baseCube);
}

return sqlQuery.toString();
}
Expand Down
52 changes: 52 additions & 0 deletions testsrc/main/mondrian/rolap/VirtualCubeTest.java
Expand Up @@ -144,6 +144,58 @@ private void checkXxx(TestContext testContext) {
"Row #0: 266,773\n"));
}

public void testCartesianJoin() {
// these examples caused cartesian joins to occur, a fix in SqlTupleReader
// was made and now these queries run normally.
TestContext testContext = createContextWithNonDefaultAllMember();

testContext.assertQueryReturns(
"select " +
"{ [measures].[store sales], [measures].[warehouse sales] } on 0, " +
"non empty { [product].[product family].members } on 1 " +
"from [warehouse and sales] " +
"where [store].[all stores].[usa].[or]",
fold(
"Axis #0:\n" +
"{[Store].[All Stores].[USA].[OR]}\n" +
"Axis #1:\n" +
"{[Measures].[Store Sales]}\n" +
"{[Measures].[Warehouse Sales]}\n" +
"Axis #2:\n" +
"{[Product].[All Products].[Drink]}\n" +
"{[Product].[All Products].[Food]}\n" +
"{[Product].[All Products].[Non-Consumable]}\n" +
"Row #0: 12,137.29\n" +
"Row #0: 3,986.32\n" +
"Row #1: 102,564.67\n" +
"Row #1: 26,496.483\n" +
"Row #2: 27,575.11\n" +
"Row #2: 8,352.25\n"));

testContext.assertQueryReturns(
"select " +
"{ [measures].[warehouse sales], [measures].[store sales] } on 0, " +
"non empty { [product].[product family].members } on 1 " +
"from [warehouse and sales] " +
"where [store].[all stores].[usa].[or]",
fold(
"Axis #0:\n" +
"{[Store].[All Stores].[USA].[OR]}\n" +
"Axis #1:\n" +
"{[Measures].[Warehouse Sales]}\n" +
"{[Measures].[Store Sales]}\n" +
"Axis #2:\n" +
"{[Product].[All Products].[Drink]}\n" +
"{[Product].[All Products].[Food]}\n" +
"{[Product].[All Products].[Non-Consumable]}\n" +
"Row #0: 3,986.32\n" +
"Row #0: 12,137.29\n" +
"Row #1: 26,496.483\n" +
"Row #1: 102,564.67\n" +
"Row #2: 8,352.25\n" +
"Row #2: 27,575.11\n"));
}

/**
* Query a virtual cube that contains a non-conforming dimension that
* does not have ALL as its default member.
Expand Down

0 comments on commit 56261f8

Please sign in to comment.