Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MONDRIAN: [MONDRIAN-944] Adds the first version of native support for…
… Filter matching operations. It still needs to support aggregate tables. It can't use native matching natively for any arguments of filter. Currently, only the following syntax gets transformed into a native filter match: Filter([Dimension].[Level].Members, [Dimension].CurrentMember.Caption Matches ( [ regexp here ] ) Filter([Dimension].[Level].Members, [Dimension].CurrentMember.Name Matches ( [ regexp here ] ) As of now, it passes the regexp directly from MDX to SQL. There is no conversion made since there is no standard way to convert regular expressions from Java to SQL. Next step is to implement a conversion helper inside of RolapNativeSql.MatchingSqlCompiler. Maybe this needs to be in JdbcDialectImpl. Only the Oracle dialect currently supports regular expression matching for native filters. We will add new implementations for the different dialects as we go along and do the research on each of those. [git-p4: depot-paths = "//open/mondrian/": change = 14305]
- Loading branch information
1 parent
270bdde
commit 7535f2b
Showing
9 changed files
with
258 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
// $Id$ | ||
// This software is subject to the terms of the Eclipse Public License v1.0 | ||
// Agreement, available at the following URL: | ||
// http://www.eclipse.org/legal/epl-v10.html. | ||
// Copyright (C) 2011 Julian Hyde | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package mondrian.rolap; | ||
|
||
import mondrian.olap.MondrianProperties; | ||
import mondrian.spi.Dialect; | ||
import mondrian.test.SqlPattern; | ||
|
||
public class NativeFilterMatchingTest extends BatchTestCase { | ||
public void testBugMondrian944() throws Exception { | ||
propSaver.set( | ||
MondrianProperties.instance().EnableNativeRegexpFilter, | ||
true); | ||
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.*') order by \"customer\".\"country\" ASC, \"customer\".\"state_province\" ASC, \"customer\".\"city\" ASC, \"fname\" || ' ' || \"lname\" ASC"; | ||
SqlPattern[] patterns = { | ||
new SqlPattern( | ||
Dialect.DatabaseProduct.ORACLE, | ||
sqlOracle, | ||
sqlOracle.length()) | ||
}; | ||
final String query = | ||
"With\n" | ||
+ "Set [*NATIVE_CJ_SET] as 'Filter([*BASE_MEMBERS_Customers], Not IsEmpty ([Measures].[Unit Sales]))'\n" | ||
+ "Set [*SORTED_COL_AXIS] as 'Order([*CJ_COL_AXIS],[Customers].CurrentMember.OrderKey,BASC,Ancestor([Customers].CurrentMember,[Customers].[City]).OrderKey,BASC)'\n" | ||
+ "Set [*BASE_MEMBERS_Customers] as 'Filter([Customers].[Name].Members,[Customers].CurrentMember.Caption Matches (\".*Jeanne.*\"))'\n" | ||
+ "Set [*BASE_MEMBERS_Measures] as '{[Measures].[*FORMATTED_MEASURE_0]}'\n" | ||
+ "Set [*CJ_COL_AXIS] as 'Generate([*NATIVE_CJ_SET], {([Customers].currentMember)})'\n" | ||
+ "Member [Measures].[*FORMATTED_MEASURE_0] as '[Measures].[Unit Sales]', FORMAT_STRING = 'Standard', SOLVE_ORDER=400\n" | ||
+ "Select\n" | ||
+ "CrossJoin([*SORTED_COL_AXIS],[*BASE_MEMBERS_Measures]) on columns\n" | ||
+ "From [Sales]"; | ||
assertQuerySqlOrNot( | ||
getTestContext(), | ||
query, | ||
patterns, | ||
false, | ||
true, | ||
true); | ||
assertQueryReturns( | ||
query, | ||
"Axis #0:\n" | ||
+ "{}\n" | ||
+ "Axis #1:\n" | ||
+ "{[Customers].[USA].[WA].[Issaquah].[Jeanne Derry], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[CA].[Los Angeles].[Jeannette Eldridge], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[CA].[Burbank].[Jeanne Bohrnstedt], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[OR].[Portland].[Jeanne Zysko], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[WA].[Everett].[Jeanne McDill], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[CA].[West Covina].[Jeanne Whitaker], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[WA].[Everett].[Jeanne Turner], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[WA].[Puyallup].[Jeanne Wentz], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[OR].[Albany].[Jeannette Bura], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "{[Customers].[USA].[WA].[Lynnwood].[Jeanne Ibarra], [Measures].[*FORMATTED_MEASURE_0]}\n" | ||
+ "Row #0: 50\n" | ||
+ "Row #0: 21\n" | ||
+ "Row #0: 31\n" | ||
+ "Row #0: 42\n" | ||
+ "Row #0: 110\n" | ||
+ "Row #0: 59\n" | ||
+ "Row #0: 42\n" | ||
+ "Row #0: 157\n" | ||
+ "Row #0: 146\n" | ||
+ "Row #0: 78\n"); | ||
} | ||
} | ||
// End NativeFilterMatchingTest.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters