Skip to content

Commit

Permalink
MONDRIAN: Fixes failing tests following the refactoring of the way di…
Browse files Browse the repository at this point in the history
…alects handle nulls.

[git-p4: depot-paths = "//open/mondrian/": change = 14488]
  • Loading branch information
lucboudreau committed Jul 25, 2011
1 parent 75eb7cb commit 7c23ec7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 109 deletions.
8 changes: 4 additions & 4 deletions testsrc/main/mondrian/olap/fun/NativizeSetFunDefTest.java
Expand Up @@ -1468,11 +1468,11 @@ public void testSingleLevelDotMembersIsNativelyEvaluated() {
+ "\"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", "
+ "\"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", "
+ "\"customer\".\"yearly_income\" "
+ "order by \"customer\".\"country\" ASC, "
+ "\"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, "
+ "\"fname\" || ' ' || \"lname\" ASC";
+ "order by \"customer\".\"country\" ASC NULLS LAST, "
+ "\"customer\".\"state_province\" ASC NULLS LAST, \"customer\".\"city\" ASC NULLS LAST, "
+ "\"fname\" || ' ' || \"lname\" ASC NULLS LAST";
SqlPattern oraclePattern =
new SqlPattern(Dialect.DatabaseProduct.ORACLE, sql, 852);
new SqlPattern(Dialect.DatabaseProduct.ORACLE, sql, sql.length());
assertQuerySql(mdx1, new SqlPattern[]{oraclePattern});
assertQuerySql(mdx2, new SqlPattern[]{oraclePattern});
}
Expand Down
4 changes: 2 additions & 2 deletions testsrc/main/mondrian/rolap/NativeFilterMatchingTest.java
Expand Up @@ -18,7 +18,7 @@
public class NativeFilterMatchingTest extends BatchTestCase {
public void testPositiveMatching() throws Exception {
final String sqlOracle =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\", \"time_by_day\" \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having REGEXP_LIKE(\"fname\" || ' ' || \"lname\", '.*jeanne.*', 'i') order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, \"fname\" || ' ' || \"lname\" ASC";
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\", \"time_by_day\" \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having REGEXP_LIKE(\"fname\" || ' ' || \"lname\", '.*jeanne.*', 'i') order by \"customer\".\"country\" ASC NULLS LAST, \"customer\".\"state_province\" ASC NULLS LAST, \"customer\".\"city\" ASC NULLS LAST, \"fname\" || ' ' || \"lname\" ASC NULLS LAST";
final String sqlPgsql =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", fullname as \"c4\", fullname as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" as \"customer\", \"sales_fact_1997\" as \"sales_fact_1997\", \"time_by_day\" as \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", fullname, \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having fullname ~ '(?i).*jeanne.*' order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, fullname ASC";
final String sqlMysql =
Expand Down Expand Up @@ -86,7 +86,7 @@ public void testPositiveMatching() throws Exception {

public void testNegativeMatching() throws Exception {
final String sqlOracle =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\", \"time_by_day\" \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having NOT(REGEXP_LIKE(\"fname\" || ' ' || \"lname\", '.*jeanne.*', 'i')) order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, \"fname\" || ' ' || \"lname\" ASC";
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\", \"time_by_day\" \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having NOT(REGEXP_LIKE(\"fname\" || ' ' || \"lname\", '.*jeanne.*', 'i')) order by \"customer\".\"country\" ASC NULLS LAST, \"customer\".\"state_province\" ASC NULLS LAST, \"customer\".\"city\" ASC NULLS LAST, \"fname\" || ' ' || \"lname\" ASC NULLS LAST";
final String sqlPgsql =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", fullname as \"c4\", fullname as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" as \"customer\", \"sales_fact_1997\" as \"sales_fact_1997\", \"time_by_day\" as \"time_by_day\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and \"sales_fact_1997\".\"time_id\" = \"time_by_day\".\"time_id\" and \"time_by_day\".\"the_year\" = 1997 group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", fullname, \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" having NOT(fullname ~ '(?i).*jeanne.*') order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, fullname ASC";
final String sqlMysql =
Expand Down
129 changes: 26 additions & 103 deletions testsrc/main/mondrian/rolap/NonEmptyTest.java
Expand Up @@ -4278,36 +4278,15 @@ public void testConstrainedMeasureGetsOptimized() {
+ "[Measures].[unit sales Female], [Measures].[store sales Female]} on 0, "
+ "non empty [Customers].[name].members on 1 "
+ "from Sales";
final SqlPattern pattern = new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
"select \"customer\".\"country\" as \"c0\", "
+ "\"customer\".\"state_province\" as \"c1\", "
+ "\"customer\".\"city\" as \"c2\", "
+ "\"customer\".\"customer_id\" as \"c3\", "
+ "\"fname\" || ' ' || \"lname\" as \"c4\", "
+ "\"fname\" || ' ' || \"lname\" as \"c5\", "
+ "\"customer\".\"gender\" as \"c6\", "
+ "\"customer\".\"marital_status\" as \"c7\", "
+ "\"customer\".\"education\" as \"c8\", "
+ "\"customer\".\"yearly_income\" as \"c9\" "
+ "from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\" "
+ "where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" "
+ "and (\"customer\".\"gender\" in ('M', 'F')) "
+ "group by \"customer\".\"country\", "
+ "\"customer\".\"state_province\", "
+ "\"customer\".\"city\", "
+ "\"customer\".\"customer_id\", "
+ "\"fname\" || ' ' || \"lname\", "
+ "\"customer\".\"gender\", "
+ "\"customer\".\"marital_status\", "
+ "\"customer\".\"education\", "
+ "\"customer\".\"yearly_income\" "
+ "order by \"customer\".\"country\" ASC,"
+ " \"customer\".\"state_province\" ASC,"
+ " \"customer\".\"city\" ASC, "
+ "\"fname\" || ' ' || \"lname\" ASC",
860);
assertQuerySql(mdx, new SqlPattern[]{pattern});
final String sqlOracle =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and (\"customer\".\"gender\" in ('M', 'F')) group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" order by \"customer\".\"country\" ASC NULLS LAST, \"customer\".\"state_province\" ASC NULLS LAST, \"customer\".\"city\" ASC NULLS LAST, \"fname\" || ' ' || \"lname\" ASC NULLS LAST";
assertQuerySql(
mdx,
new SqlPattern[]{
new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
sqlOracle,
sqlOracle.length())});
}

public void testNestedMeasureConstraintsGetOptimized() {
Expand All @@ -4318,8 +4297,7 @@ public void testNestedMeasureConstraintsGetOptimized() {
+ "non empty {[Measures].[unit sales Male Married]} on 0, "
+ "non empty [Customers].[name].members on 1 "
+ "from Sales";
SqlPattern pattern = new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
final String sqlOracle =
"select \"customer\".\"country\" as \"c0\", "
+ "\"customer\".\"state_province\" as \"c1\", "
+ "\"customer\".\"city\" as \"c2\", "
Expand All @@ -4344,11 +4322,14 @@ public void testNestedMeasureConstraintsGetOptimized() {
+ "\"customer\".\"marital_status\", "
+ "\"customer\".\"education\", "
+ "\"customer\".\"yearly_income\" "
+ "order by \"customer\".\"country\" ASC, "
+ "\"customer\".\"state_province\" ASC, "
+ "\"customer\".\"city\" ASC, "
+ "\"fname\" || \" \" || \"lname\" ASC",
892);
+ "order by \"customer\".\"country\" ASC NULLS LAST, "
+ "\"customer\".\"state_province\" ASC NULLS LAST, "
+ "\"customer\".\"city\" ASC NULLS LAST, "
+ "\"fname\" || \" \" || \"lname\" ASC NULLS LAST";
SqlPattern pattern = new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
sqlOracle,
sqlOracle.length());
assertQuerySql(mdx, new SqlPattern[]{pattern});
}

Expand Down Expand Up @@ -4385,10 +4366,10 @@ public void testNonUniformNestedMeasureConstraintsGetOptimized() {
+ "\"customer\".\"marital_status\", "
+ "\"customer\".\"education\", "
+ "\"customer\".\"yearly_income\" "
+ "order by \"customer\".\"country\" ASC,"
+ " \"customer\".\"state_province\" ASC,"
+ " \"customer\".\"city\" ASC, "
+ "\"fname\" || ' ' || \"lname\" ASC",
+ "order by \"customer\".\"country\" ASC NULLS LAST,"
+ " \"customer\".\"state_province\" ASC NULLS LAST,"
+ " \"customer\".\"city\" ASC NULLS LAST, "
+ "\"fname\" || ' ' || \"lname\" ASC NULLS LAST",
852);
assertQuerySql(mdx, new SqlPattern[]{pattern});
}
Expand All @@ -4401,29 +4382,12 @@ public void testNonUniformConstraintsAreNotUsedForOptimization() {
+ "non empty {[Measures].[unit sales Male], [Measures].[unit sales Married]} on 0, "
+ "non empty [Customers].[name].members on 1 "
+ "from Sales";
final String sqlOracle =
"select \"customer\".\"country\" as \"c0\", \"customer\".\"state_province\" as \"c1\", \"customer\".\"city\" as \"c2\", \"customer\".\"customer_id\" as \"c3\", \"fname\" || ' ' || \"lname\" as \"c4\", \"fname\" || ' ' || \"lname\" as \"c5\", \"customer\".\"gender\" as \"c6\", \"customer\".\"marital_status\" as \"c7\", \"customer\".\"education\" as \"c8\", \"customer\".\"yearly_income\" as \"c9\" from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\" where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" and (\"customer\".\"gender\" in ('M', 'F')) group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", \"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", \"customer\".\"gender\", \"customer\".\"marital_status\", \"customer\".\"education\", \"customer\".\"yearly_income\" order by \"customer\".\"country\" ASC NULLS LAST, \"customer\".\"state_province\" ASC NULLS LAST, \"customer\".\"city\" ASC NULLS LAST, \"fname\" || ' ' || \"lname\" ASC NULLS LAST";
final SqlPattern pattern = new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
"select \"customer\".\"country\" as \"c0\", "
+ "\"customer\".\"state_province\" as \"c1\", "
+ "\"customer\".\"city\" as \"c2\", "
+ "\"customer\".\"customer_id\" as \"c3\", "
+ "\"fname\" || ' ' || \"lname\" as \"c4\", "
+ "\"fname\" || ' ' || \"lname\" as \"c5\", "
+ "\"customer\".\"gender\" as \"c6\", "
+ "\"customer\".\"marital_status\" as \"c7\", "
+ "\"customer\".\"education\" as \"c8\", "
+ "\"customer\".\"yearly_income\" as \"c9\" "
+ "from \"customer\" \"customer\", \"sales_fact_1997\" \"sales_fact_1997\" "
+ "where \"sales_fact_1997\".\"customer_id\" = \"customer\".\"customer_id\" "
+ "and (\"customer\".\"marital_status\" = 'M') and (\"customer\".\"gender\" = 'M') "
+ "group by \"customer\".\"country\", \"customer\".\"state_province\", \"customer\".\"city\", "
+ "\"customer\".\"customer_id\", \"fname\" || ' ' || \"lname\", "
+ "\"customer\".\"gender\", \"customer\".\"marital_status\", "
+ "\"customer\".\"education\", \"customer\".\"yearly_income\" "
+ "order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, "
+ "\"customer\".\"city\" ASC, "
+ "\"fname\" || ' ' || \"lname\" ASC",
892);
sqlOracle,
sqlOracle.length());
assertQuerySqlOrNot(
getTestContext(), mdx, new SqlPattern[]{pattern},true, false, true);
}
Expand Down Expand Up @@ -4851,47 +4815,6 @@ public void testBugMondrian897DoubleNamedSetDefinitions() {
+ "Row #2: \n"
+ "Row #3: \n");
}

public void testBugY() throws Exception {
final String sqlOracle =
"select \"store\".\"store_country\" as \"c0\""
+ " from \"store\" \"store\""
+ " group by \"store\".\"store_country\" order by \"store\".\"store_country\" ASC";
SqlPattern[] patterns = {
new SqlPattern(
Dialect.DatabaseProduct.ORACLE,
sqlOracle,
sqlOracle.length())
};

final String query =
"With Set [*NATIVE_CJ_SET] as 'NonEmptyCrossJoin([*BASE_MEMBERS_Product],[*BASE_MEMBERS_Fact Attribute])'\n"
+ "Set [*SORTED_ROW_AXIS] as 'Order([*CJ_ROW_AXIS],[Product].CurrentMember.OrderKey,BASC,[Store Country].CurrentMember.OrderKey,BASC)'\n"
+ "Set [*BASE_MEMBERS_Product] as '[Product].[Product Family].Members'\n"
+ "Set [*BASE_MEMBERS_Measures] as '{[Measures].[*FORMATTED_MEASURE_0]}'\n"
+ "Set [*CJ_ROW_AXIS] as 'Generate([*NATIVE_CJ_SET], {([Product].currentMember,[Store Country].currentMember)})'\n"
+ "Set [*BASE_MEMBERS_Fact Attribute] as '{[Store Country].[USA]}'\n"
+ "Set [*CJ_COL_AXIS] as '[*NATIVE_CJ_SET]'\n"
+ "Member [Measures].[*FORMATTED_MEASURE_0] as '[Measures].[Unit Sales]', FORMAT_STRING = 'Standard', SOLVE_ORDER=400\n"
+ "Select [*BASE_MEMBERS_Measures] on columns, Non Empty [*SORTED_ROW_AXIS] on rows\n"
+ "From [Sales]";

final TestContext context =
TestContext.createSubstitutingCube(
"Sales",
"<DimensionUsage name=\"Store\" highCardinality=\"true\" source=\"Store\" foreignKey=\"store_id\"/>",
null,
null,
null);

assertQuerySqlOrNot(
context,
query,
patterns,
true,
true,
true);
}
}

// End NonEmptyTest.java

0 comments on commit 7c23ec7

Please sign in to comment.