From 05f132e572ba56a753fc1c507b37425a8e82d8a4 Mon Sep 17 00:00:00 2001 From: Luc Boudreau Date: Sun, 30 Oct 2011 15:59:45 -0800 Subject: [PATCH] MONDRIAN: [MONDRIAN-952] Adds more tests for non-collapsed aggregate levels. [git-p4: depot-paths = "//open/mondrian/": change = 14727] --- .../rolap/TestAggregationManager.java | 84 +++++++ testsrc/main/mondrian/test/SchemaTest.java | 221 ++++++++++++++++++ 2 files changed, 305 insertions(+) diff --git a/testsrc/main/mondrian/rolap/TestAggregationManager.java b/testsrc/main/mondrian/rolap/TestAggregationManager.java index 257acb3063..0180d44a5d 100644 --- a/testsrc/main/mondrian/rolap/TestAggregationManager.java +++ b/testsrc/main/mondrian/rolap/TestAggregationManager.java @@ -1926,6 +1926,90 @@ public void testNonCollapsedAggregate() throws Exception { }, false, false, true); } + + public void testTwoNonCollapsedAggregate() throws Exception { + propSaver.set(MondrianProperties.instance().UseAggregates, true); + propSaver.set(MondrianProperties.instance().ReadAggregates, true); + final String cube = + "\n" + + " \n" + + " " + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "\n" + + "\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n"; + final TestContext context = + TestContext.instance().create( + null, cube, null, null, null, null); + final String mdx = + "select {Crossjoin([Product].[Product Family].Members, [Store].[Store Id].Members)} on rows, {[Measures].[Unit Sales]} on columns from [Foo]"; + final String sqlOracle = + "select \"product_class\".\"product_family\" as \"c0\", \"store\".\"store_id\" as \"c1\", sum(\"agg_l_05_sales_fact_1997\".\"unit_sales\") as \"m0\" from \"product_class\" \"product_class\", \"product\" \"product\", \"agg_l_05_sales_fact_1997\" \"agg_l_05_sales_fact_1997\", \"store\" \"store\" where \"agg_l_05_sales_fact_1997\".\"product_id\" = \"product\".\"product_id\" and \"product\".\"product_class_id\" = \"product_class\".\"product_class_id\" and \"agg_l_05_sales_fact_1997\".\"store_id\" = \"store\".\"store_id\" group by \"product_class\".\"product_family\", \"store\".\"store_id\""; + final String sqlMysql = + "select `product_class`.`product_family` as `c0`, `store`.`store_id` as `c1`, sum(`agg_l_05_sales_fact_1997`.`unit_sales`) as `m0` from `product_class` as `product_class`, `product` as `product`, `agg_l_05_sales_fact_1997` as `agg_l_05_sales_fact_1997`, `store` as `store` where `agg_l_05_sales_fact_1997`.`product_id` = `product`.`product_id` and `product`.`product_class_id` = `product_class`.`product_class_id` and `agg_l_05_sales_fact_1997`.`store_id` = `store`.`store_id` group by `product_class`.`product_family`, `store`.`store_id`"; + assertQuerySqlOrNot( + context, + mdx, + new SqlPattern[] { + new SqlPattern( + Dialect.DatabaseProduct.ORACLE, + sqlOracle, + sqlOracle.length()), + new SqlPattern( + Dialect.DatabaseProduct.MYSQL, + sqlMysql, + sqlMysql.length()) + }, + false, false, true); + } } // End TestAggregationManager.java diff --git a/testsrc/main/mondrian/test/SchemaTest.java b/testsrc/main/mondrian/test/SchemaTest.java index 41bd2e2b32..c4e4f5c568 100644 --- a/testsrc/main/mondrian/test/SchemaTest.java +++ b/testsrc/main/mondrian/test/SchemaTest.java @@ -3943,6 +3943,227 @@ public void testNonCollapsedAggregate() throws Exception { + "Row #2: 50,236\n"); } + public void testTwoNonCollapsedAggregate() throws Exception { + propSaver.set(MondrianProperties.instance().UseAggregates, true); + propSaver.set(MondrianProperties.instance().ReadAggregates, true); + final String cube = + "\n" + + "
\n" + + " " + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "\n" + + "\n" + + " \n" + + " \n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "
\n" + + "
\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n"; + final TestContext context = + TestContext.instance().create( + null, cube, null, null, null, null); + context.assertQueryReturns( + "select {Crossjoin([Product].[Product Family].Members, [Store].[Store Id].Members)} on rows, {[Measures].[Unit Sales]} on columns from [Foo]", + "Axis #0:\n" + + "{}\n" + + "Axis #1:\n" + + "{[Measures].[Unit Sales]}\n" + + "Axis #2:\n" + + "{[Product].[Drink], [Store].[Acapulco].[1]}\n" + + "{[Product].[Drink], [Store].[Bellingham].[2]}\n" + + "{[Product].[Drink], [Store].[Beverly Hills].[6]}\n" + + "{[Product].[Drink], [Store].[Bremerton].[3]}\n" + + "{[Product].[Drink], [Store].[Camacho].[4]}\n" + + "{[Product].[Drink], [Store].[Guadalajara].[5]}\n" + + "{[Product].[Drink], [Store].[Hidalgo].[12]}\n" + + "{[Product].[Drink], [Store].[Hidalgo].[18]}\n" + + "{[Product].[Drink], [Store].[Los Angeles].[7]}\n" + + "{[Product].[Drink], [Store].[Merida].[8]}\n" + + "{[Product].[Drink], [Store].[Mexico City].[9]}\n" + + "{[Product].[Drink], [Store].[None].[0]}\n" + + "{[Product].[Drink], [Store].[Orizaba].[10]}\n" + + "{[Product].[Drink], [Store].[Portland].[11]}\n" + + "{[Product].[Drink], [Store].[Salem].[13]}\n" + + "{[Product].[Drink], [Store].[San Andres].[21]}\n" + + "{[Product].[Drink], [Store].[San Diego].[24]}\n" + + "{[Product].[Drink], [Store].[San Francisco].[14]}\n" + + "{[Product].[Drink], [Store].[Seattle].[15]}\n" + + "{[Product].[Drink], [Store].[Spokane].[16]}\n" + + "{[Product].[Drink], [Store].[Tacoma].[17]}\n" + + "{[Product].[Drink], [Store].[Vancouver].[19]}\n" + + "{[Product].[Drink], [Store].[Victoria].[20]}\n" + + "{[Product].[Drink], [Store].[Walla Walla].[22]}\n" + + "{[Product].[Drink], [Store].[Yakima].[23]}\n" + + "{[Product].[Food], [Store].[Acapulco].[1]}\n" + + "{[Product].[Food], [Store].[Bellingham].[2]}\n" + + "{[Product].[Food], [Store].[Beverly Hills].[6]}\n" + + "{[Product].[Food], [Store].[Bremerton].[3]}\n" + + "{[Product].[Food], [Store].[Camacho].[4]}\n" + + "{[Product].[Food], [Store].[Guadalajara].[5]}\n" + + "{[Product].[Food], [Store].[Hidalgo].[12]}\n" + + "{[Product].[Food], [Store].[Hidalgo].[18]}\n" + + "{[Product].[Food], [Store].[Los Angeles].[7]}\n" + + "{[Product].[Food], [Store].[Merida].[8]}\n" + + "{[Product].[Food], [Store].[Mexico City].[9]}\n" + + "{[Product].[Food], [Store].[None].[0]}\n" + + "{[Product].[Food], [Store].[Orizaba].[10]}\n" + + "{[Product].[Food], [Store].[Portland].[11]}\n" + + "{[Product].[Food], [Store].[Salem].[13]}\n" + + "{[Product].[Food], [Store].[San Andres].[21]}\n" + + "{[Product].[Food], [Store].[San Diego].[24]}\n" + + "{[Product].[Food], [Store].[San Francisco].[14]}\n" + + "{[Product].[Food], [Store].[Seattle].[15]}\n" + + "{[Product].[Food], [Store].[Spokane].[16]}\n" + + "{[Product].[Food], [Store].[Tacoma].[17]}\n" + + "{[Product].[Food], [Store].[Vancouver].[19]}\n" + + "{[Product].[Food], [Store].[Victoria].[20]}\n" + + "{[Product].[Food], [Store].[Walla Walla].[22]}\n" + + "{[Product].[Food], [Store].[Yakima].[23]}\n" + + "{[Product].[Non-Consumable], [Store].[Acapulco].[1]}\n" + + "{[Product].[Non-Consumable], [Store].[Bellingham].[2]}\n" + + "{[Product].[Non-Consumable], [Store].[Beverly Hills].[6]}\n" + + "{[Product].[Non-Consumable], [Store].[Bremerton].[3]}\n" + + "{[Product].[Non-Consumable], [Store].[Camacho].[4]}\n" + + "{[Product].[Non-Consumable], [Store].[Guadalajara].[5]}\n" + + "{[Product].[Non-Consumable], [Store].[Hidalgo].[12]}\n" + + "{[Product].[Non-Consumable], [Store].[Hidalgo].[18]}\n" + + "{[Product].[Non-Consumable], [Store].[Los Angeles].[7]}\n" + + "{[Product].[Non-Consumable], [Store].[Merida].[8]}\n" + + "{[Product].[Non-Consumable], [Store].[Mexico City].[9]}\n" + + "{[Product].[Non-Consumable], [Store].[None].[0]}\n" + + "{[Product].[Non-Consumable], [Store].[Orizaba].[10]}\n" + + "{[Product].[Non-Consumable], [Store].[Portland].[11]}\n" + + "{[Product].[Non-Consumable], [Store].[Salem].[13]}\n" + + "{[Product].[Non-Consumable], [Store].[San Andres].[21]}\n" + + "{[Product].[Non-Consumable], [Store].[San Diego].[24]}\n" + + "{[Product].[Non-Consumable], [Store].[San Francisco].[14]}\n" + + "{[Product].[Non-Consumable], [Store].[Seattle].[15]}\n" + + "{[Product].[Non-Consumable], [Store].[Spokane].[16]}\n" + + "{[Product].[Non-Consumable], [Store].[Tacoma].[17]}\n" + + "{[Product].[Non-Consumable], [Store].[Vancouver].[19]}\n" + + "{[Product].[Non-Consumable], [Store].[Victoria].[20]}\n" + + "{[Product].[Non-Consumable], [Store].[Walla Walla].[22]}\n" + + "{[Product].[Non-Consumable], [Store].[Yakima].[23]}\n" + + "Row #0: \n" + + "Row #1: 208\n" + + "Row #2: 1,945\n" + + "Row #3: 2,288\n" + + "Row #4: \n" + + "Row #5: \n" + + "Row #6: \n" + + "Row #7: \n" + + "Row #8: 2,422\n" + + "Row #9: \n" + + "Row #10: \n" + + "Row #11: \n" + + "Row #12: \n" + + "Row #13: 2,371\n" + + "Row #14: 3,735\n" + + "Row #15: \n" + + "Row #16: 2,560\n" + + "Row #17: 175\n" + + "Row #18: 2,213\n" + + "Row #19: 2,238\n" + + "Row #20: 3,092\n" + + "Row #21: \n" + + "Row #22: \n" + + "Row #23: 191\n" + + "Row #24: 1,159\n" + + "Row #25: \n" + + "Row #26: 1,587\n" + + "Row #27: 15,438\n" + + "Row #28: 17,809\n" + + "Row #29: \n" + + "Row #30: \n" + + "Row #31: \n" + + "Row #32: \n" + + "Row #33: 18,294\n" + + "Row #34: \n" + + "Row #35: \n" + + "Row #36: \n" + + "Row #37: \n" + + "Row #38: 18,632\n" + + "Row #39: 29,905\n" + + "Row #40: \n" + + "Row #41: 18,369\n" + + "Row #42: 1,555\n" + + "Row #43: 18,159\n" + + "Row #44: 16,925\n" + + "Row #45: 25,453\n" + + "Row #46: \n" + + "Row #47: \n" + + "Row #48: 1,622\n" + + "Row #49: 8,192\n" + + "Row #50: \n" + + "Row #51: 442\n" + + "Row #52: 3,950\n" + + "Row #53: 4,479\n" + + "Row #54: \n" + + "Row #55: \n" + + "Row #56: \n" + + "Row #57: \n" + + "Row #58: 4,947\n" + + "Row #59: \n" + + "Row #60: \n" + + "Row #61: \n" + + "Row #62: \n" + + "Row #63: 5,076\n" + + "Row #64: 7,940\n" + + "Row #65: \n" + + "Row #66: 4,706\n" + + "Row #67: 387\n" + + "Row #68: 4,639\n" + + "Row #69: 4,428\n" + + "Row #70: 6,712\n" + + "Row #71: \n" + + "Row #72: \n" + + "Row #73: 390\n" + + "Row #74: 2,140\n"); + } + public void testCollapsedError() throws Exception { propSaver.set(MondrianProperties.instance().UseAggregates, true); propSaver.set(MondrianProperties.instance().ReadAggregates, true);