Skip to content

Commit

Permalink
MONDRIAN: (LER-4850) add property
Browse files Browse the repository at this point in the history
mondrian.rolap.ignoreInvalidMembersDuringQuery 
to convert invalid members to null member during query
(existing property ignoreInvalidMembers only affects schema
load); no warning support yet

[git-p4: depot-paths = "//open/mondrian/": change = 9198]
  • Loading branch information
jsichi committed May 2, 2007
1 parent 3a1b346 commit 7031079
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 5 deletions.
7 changes: 7 additions & 0 deletions doc/configuration.html
Expand Up @@ -323,6 +323,13 @@ <h3>1.1 Property list<a name="Property_list">&nbsp;</a></h3>
and will be treated as a null member if they are later referenced in
a query.</td>
</tr>
<tr>
<td><code><a href="api/mondrian/olap/MondrianProperties.html#IgnoreInvalidMembersDuringQuery">mondrian.rolap.ignoreInvalidMembersDuringQuery</a></code></td>
<td>boolean</td>
<td>false</td>
<td>If set to true, during query validation, invalid members are ignored
and will be treated as a null member.</td>
</tr>
<tr>
<td><code><a href="api/mondrian/olap/MondrianProperties.html#IterationLimit">mondrian.rolap.IterationLimit</a></code></td>
<td>int</td>
Expand Down
6 changes: 6 additions & 0 deletions mondrian.properties
Expand Up @@ -275,6 +275,12 @@ RoleXX='California manager';
# treated as a null member.
mondrian.rolap.ignoreInvalidMembers=false

###############################################################################
# Boolean property indicating whether errors related to non-existent members
# should be ignored during query validation. If so, the non-existent member is
# treated as a null member.
mondrian.rolap.ignoreInvalidMembersDuringQuery=false

###############################################################################
# Integer property indicating the maximum number of iterations allowed when
# iterating over members to compute aggregates. Default of 0 indicates no
Expand Down
10 changes: 9 additions & 1 deletion src/main/mondrian/olap/MondrianProperties.java
Expand Up @@ -867,11 +867,19 @@ public Property getPropertyDefinition(String path) {

/**
* Whether non-existent member errors should be ignored during schema
* load
* load.
*/
public final BooleanProperty IgnoreInvalidMembers = new BooleanProperty(
this, "mondrian.rolap.ignoreInvalidMembers", false);

/**
* Whether non-existent member errors should be ignored during query
* validation.
*/
public final BooleanProperty IgnoreInvalidMembersDuringQuery
= new BooleanProperty(
this, "mondrian.rolap.ignoreInvalidMembersDuringQuery", false);

/**
* Iteration limit when computing an aggregate; 0 indicates unlimited
*/
Expand Down
13 changes: 9 additions & 4 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -400,13 +400,18 @@ public void resolve() {
}

/**
* @return true if Query object is being accessed during schema load
* and the property to ignore invalid members is set to true
* @return true if the relevant property for ignoring invalid members is
* set to true for this query's environment (a different property is
* checked depending on whether environment is schema load vs query
* validation)
*/
public boolean ignoreInvalidMembers()
{
return load &&
MondrianProperties.instance().IgnoreInvalidMembers.get();
MondrianProperties props = MondrianProperties.instance();
return
(load && props.IgnoreInvalidMembers.get())
||
(!load && props.IgnoreInvalidMembersDuringQuery.get());
}

/**
Expand Down
33 changes: 33 additions & 0 deletions testsrc/main/mondrian/test/BasicQueryTest.java
Expand Up @@ -5226,6 +5226,39 @@ public void testBadMeasure2() {
"must contain either a source column or a source expression, but not both");
}

public void testInvalidMembersInQuery() {
String mdx =
"select {[Measures].[Unit Sales]} on columns,\n" +
" {[Time].[1997].[Q1], [Time].[1997].[QTOO]} on rows\n" +
"from [Sales]";

// By default, reference to invalid member should cause
// query failure.
assertThrows(
mdx,
"MDX object '[Time].[1997].[QTOO]' not found in cube 'Sales'");

// Now set property
final MondrianProperties properties = MondrianProperties.instance();

boolean saved = properties.IgnoreInvalidMembersDuringQuery.get();
try {
properties.IgnoreInvalidMembersDuringQuery.set(true);
assertQueryReturns(
mdx,
fold(
"Axis #0:\n" +
"{}\n" +
"Axis #1:\n" +
"{[Measures].[Unit Sales]}\n" +
"Axis #2:\n" +
"{[Time].[1997].[Q1]}\n" +
"Row #0: 66,291\n"));
} finally {
properties.IgnoreInvalidMembersDuringQuery.set(saved);
}
}

public void testMemberOrdinalCaching() {
final MondrianProperties properties = MondrianProperties.instance();

Expand Down

0 comments on commit 7031079

Please sign in to comment.