Skip to content

Commit

Permalink
MONDRIAN: Third round of integration for Mondrian 3.0.4, including ch…
Browse files Browse the repository at this point in the history
…anges that don't impact APIs, includes changes:

11116: Fixed copyright per Julian.
11135: Upgrade to xerces 2.6 (2.3 doesn't play well with JDK 1.6);
           Restore cell range check (an olap4j test broke because this was disabled).
11136: Downgrade to xerces 2.5 (2.6 checks XML schema validity, which causes a couple of problems). Upgrade to xmlunit 1.1. Fix a log file.
11138: testing Perforce trigger for properly prefixed
              checkin comments; this submit should pass.
11139: expose Measure constructor so temporary rolap star measures can be created
11144: add helper class CustomizedFunctionTable and
       tests. Also fix a problem where "*" function needs to look
       recursively down the stack for its expected output type.
11146: include the test class added in 11144 to the main
       test suite.
11150: Goal: Re-use Mondrian schema validation code from Workbench.
       Solution: Low-risk refactor that removed dependencies on Swing and Workbench (mondrian.gui.*).  Added validate subpackage to mondrian.gui package since validate classes still have a dependency on MondrianGuiDef. Moved validation code to ValidationUtils.
11151: add a missing object test to CustomizedParser test
11154: expose Cutomized Parser support using the Connection interface.
11157: one more interface needs to be made public for Customized
       Parser.
11164: adding more test cases for Customized Parser.
11171: Expose parser behavior control for allowing invalid
       members via the Connection interface.
11180: move public interfaces related to customized parser
       to public class methods.
11184: javadoc improvement for 11180. Also correct a comment in mondrian.properties file.
11189: Do not resolve ivy dependencies if 'skip.downloads' is set. You can specify this from the command line using 'ant -Dskip.downloads ...'.

[git-p4: depot-paths = "//open/mondrian-release/3.0/": change = 11278]
  • Loading branch information
Will Gorman committed Jul 8, 2008
1 parent 02f52ef commit 5782451
Show file tree
Hide file tree
Showing 16 changed files with 1,295 additions and 2,214 deletions.
2 changes: 1 addition & 1 deletion README.txt
Expand Up @@ -2,7 +2,7 @@ This is a source, binary or data distribution of Mondrian,
an OLAP Server written in Java.

This code is released under the terms of the Common Public
License; see LICENSE.html.
License (CPL); see LICENSE.html.

For installation instructions, see doc/install.html
(http://mondrian.pentaho.org/documentation/installation.php).
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Expand Up @@ -382,7 +382,7 @@ demo/access/MondrianFoodMart.mdb"/>
<mkdir dir="${build.dir}"/>
</target>

<target name="resolve">
<target name="resolve" unless="skip.download">
<!-- Workbench dependencies to workbench/plugins -->
<ivy:resolve file="workbench/ivy.xml"/>
<ivy:retrieve pattern="${wb.plugins.dir}/[module].[ext]"/>
Expand Down
4 changes: 2 additions & 2 deletions mondrian.properties
Expand Up @@ -337,8 +337,8 @@ mondrian.rolap.iterationLimit=0
# mondrian.rolap.RolapResult.useImplicitMembers=true

###############################################################################
# If true, a division having a non-null numerator and a null denominator
# evaluates to Infinity. If false, the same division results in Null.
# If false(default), a division having a non-null numerator and a null denominator
# evaluates to Infinity. If true, the same division results in Null.
# mondrian.olap.NullDenominatorProducesNull=false

################################################################################
Expand Down
429 changes: 16 additions & 413 deletions src/main/mondrian/gui/SchemaTreeCellRenderer.java

Large diffs are not rendered by default.

66 changes: 52 additions & 14 deletions src/main/mondrian/olap/ConnectionBase.java
Expand Up @@ -55,45 +55,83 @@ public String getFullConnectString() {
return s;
}

public Query parseQuery(String s) {
return parseQuery(s, false);
public Query parseQuery(String query) {
return parseQuery(query, null, false, false);
}

public Query parseQuery(String s, boolean load) {
public Query parseQuery(String query, boolean load) {
return parseQuery(query, null, load, false);
}

/**
* Parses a query, with specified function table and the mode for strict
* validation(if true then invalid members are not ignored).
*
* <p>This method is only used in testing and by clients that need to
* support customized parser behavior. That is why this method is not part
* of the Connection interface.
*
* @param query MDX query that requires special parsing
* @param funTable Customized function table to use in parsing
* @param strictValidation If true, do not ignore invalid members
* @return Query the corresponding Query object if parsing is successful
* @throws MondrianException if parsing fails
* @see mondrian.olap.CustomizedParserTest
*/
public Query parseQuery(String query, FunTable funTable,
boolean strictValidation) {
return parseQuery(query, funTable, false, strictValidation);
}

public Exp parseExpression(String expr) {
boolean debug = false;
if (getLogger().isDebugEnabled()) {
//debug = true;
StringBuilder buf = new StringBuilder(256);
buf.append(Util.nl);
buf.append(s);
buf.append(expr);
getLogger().debug(buf.toString());
}
try {
Parser parser = new Parser();
final FunTable funTable = getSchema().getFunTable();
Query q = parser.parseInternal(this, s, debug, funTable, load);
Exp q = parser.parseExpression(this, expr, debug, funTable);
return q;
} catch (Throwable e) {
throw MondrianResource.instance().FailedToParseQuery.ex(s, e);
} catch (Throwable exception) {
throw
MondrianResource.instance().FailedToParseQuery.ex(
expr,
exception);
}
}

public Exp parseExpression(String s) {

private Query parseQuery(String query, FunTable cftab, boolean load,
boolean strictValidation) {
Parser parser = new Parser();
boolean debug = false;
final FunTable funTable;

if (cftab == null) {
funTable = getSchema().getFunTable();
} else {
funTable = cftab;
}

if (getLogger().isDebugEnabled()) {
//debug = true;
StringBuilder buf = new StringBuilder(256);
buf.append(Util.nl);
buf.append(s);
buf.append(query);
getLogger().debug(buf.toString());
}

try {
Parser parser = new Parser();
final FunTable funTable = getSchema().getFunTable();
Exp q = parser.parseExpression(this, s, debug, funTable);
Query q =
parser.parseInternal(this, query, debug, funTable, load,
strictValidation);
return q;
} catch (Throwable e) {
throw MondrianResource.instance().FailedToParseQuery.ex(s, e);
throw MondrianResource.instance().FailedToParseQuery.ex(query, e);
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/mondrian/olap/Parser.cup
Expand Up @@ -28,6 +28,7 @@ parser code {:
private Connection mdxConnection;
private FunTable funTable;
private boolean load;
private boolean strictValidation;

/**
* Recursively parses an expression.
Expand All @@ -47,14 +48,16 @@ parser code {:
String queryString,
boolean debug,
FunTable funTable,
boolean load)
boolean load,
boolean strictValidation)
{
Symbol parse_tree = null;
this.scanner = new StringScanner(queryString, debug);
this.mdxConnection = mdxConnection;
this.queryString = queryString;
this.funTable = funTable;
this.load = load;
this.strictValidation = strictValidation;
try {
if (debug) {
parse_tree = debug_parse();
Expand Down Expand Up @@ -156,7 +159,7 @@ parser code {:
false, slicer, AxisOrdinal.SLICER,
QueryAxis.SubtotalVisibility.Undefined, new Id[0]);
return new Query(
mdxConnection, formulae, axes, cube, slicerAxis, cellProps, load);
mdxConnection, formulae, axes, cube, slicerAxis, cellProps, load, strictValidation);
}

// Override lr_parser methods for NLS. With this error handling scheme,
Expand Down
36 changes: 26 additions & 10 deletions src/main/mondrian/olap/Query.java
Expand Up @@ -150,6 +150,11 @@ public class Query extends QueryPart {
*/
private boolean load;

/**
* If true, enforce validation even when ignoreInvalidMembers is set.
*/
private boolean strictValidation;

/**
* How should the query be returned? Valid values are:
* ResultStyle.ITERABLE
Expand All @@ -173,7 +178,8 @@ public Query(
String cube,
QueryAxis slicerAxis,
QueryPart[] cellProps,
boolean load) {
boolean load,
boolean strictValidation) {
this(
connection,
Util.lookupCube(connection.getSchemaReader(), cube, true),
Expand All @@ -182,7 +188,8 @@ public Query(
slicerAxis,
cellProps,
new Parameter[0],
load);
load,
strictValidation);
}

/**
Expand All @@ -196,7 +203,8 @@ public Query(
QueryAxis slicerAxis,
QueryPart[] cellProps,
Parameter[] parameters,
boolean load) {
boolean load,
boolean strictValidation) {
this.connection = connection;
this.cube = mdxCube;
this.formulas = formulas;
Expand All @@ -213,6 +221,7 @@ public Query(
// processed natively; as we parse the query, we'll know otherwise
this.nativeCrossJoinVirtualCube = true;
this.load = load;
this.strictValidation = strictValidation;
this.alertedNonNativeFunDefs = new HashSet<FunDef>();
resolve();
}
Expand Down Expand Up @@ -284,6 +293,12 @@ public Validator createValidator() {
return new StackValidator(connection.getSchema().getFunTable());
}

public Validator createValidator(FunTable functionTable) {
StackValidator validator;
validator = new StackValidator(functionTable);
return validator;
}

public Object clone() {
return new Query(
connection,
Expand All @@ -293,7 +308,8 @@ public Object clone() {
(slicerAxis == null) ? null : (QueryAxis) slicerAxis.clone(),
cellProps,
parameters.toArray(new Parameter[parameters.size()]),
load);
load,
strictValidation);
}

public Query safeClone() {
Expand Down Expand Up @@ -426,10 +442,9 @@ public void resolve() {
public boolean ignoreInvalidMembers()
{
MondrianProperties props = MondrianProperties.instance();
return
(load && props.IgnoreInvalidMembers.get())
||
(!load && props.IgnoreInvalidMembersDuringQuery.get());
return
!strictValidation &&
((load && props.IgnoreInvalidMembers.get()) || (!load && props.IgnoreInvalidMembersDuringQuery.get()));
}

/**
Expand Down Expand Up @@ -494,7 +509,7 @@ private void compile(ExpCompiler compiler) {
*
* @param validator Validator
*/
void resolve(Validator validator) {
public void resolve(Validator validator) {
// Before commencing validation, create all calculated members,
// calculated sets, and parameters.
if (formulas != null) {
Expand Down Expand Up @@ -1361,7 +1376,8 @@ private boolean requiresExpression(int n) {
}
} else if (parent instanceof UnresolvedFunCall) {
final UnresolvedFunCall funCall = (UnresolvedFunCall) parent;
if (funCall.getSyntax() == Syntax.Parentheses) {
if (funCall.getSyntax() == Syntax.Parentheses ||
funCall.getFunName() == "*") {
return requiresExpression(n - 1);
} else {
int k = whichArg(funCall, (Exp) stack.get(n));
Expand Down
52 changes: 52 additions & 0 deletions src/main/mondrian/olap/fun/CustomizedFunctionTable.java
@@ -0,0 +1,52 @@
// $Id$
package mondrian.olap.fun;

import java.util.*;

import mondrian.olap.*;

/**
* Interface to build a customized function table, selecting functions from the set of
* supported functions in BuiltInFunTable instance.
*
* @author Rushan Chen
* @version $Id$
*/
public class CustomizedFunctionTable extends FunTableImpl {

Set<String> supportedBuiltInFunctions;
Set<FunDef> specialFunctions;

public CustomizedFunctionTable(Set<String> buildInFunctions) {
supportedBuiltInFunctions = buildInFunctions;
this.specialFunctions = new HashSet<FunDef>();
}

public CustomizedFunctionTable(Set<String> buildInFunctions, Set<FunDef> specialFunctions) {
supportedBuiltInFunctions = buildInFunctions;
this.specialFunctions = specialFunctions;
}

protected void defineFunctions() {
final FunTable builtinFunTable = BuiltinFunTable.instance();

// Includes all the keywords form builtin function table
for (String reservedWord : builtinFunTable.getReservedWords()) {
defineReserved(reservedWord);
}

// Add supported builtin functions
for (Resolver resolver : builtinFunTable.getResolvers()) {
if (supportedBuiltInFunctions.contains(resolver.getName())) {
define(resolver);
}
}

// Add special function definitions
for (FunDef funDef : specialFunctions) {
define(funDef);
}
}
}

// End CustomizedFunctionTable.java
4 changes: 2 additions & 2 deletions src/main/mondrian/olap/fun/ParenthesesFunDef.java
Expand Up @@ -27,9 +27,9 @@
* @since 3 March, 2002
* @version $Id$
*/
class ParenthesesFunDef extends FunDefBase {
public class ParenthesesFunDef extends FunDefBase {
private final int argType;
ParenthesesFunDef(int argType) {
public ParenthesesFunDef(int argType) {
super(
"()",
"(<Expression>)",
Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapStar.java
Expand Up @@ -1377,7 +1377,7 @@ public static class Measure extends Column {
private final String cubeName;
private final RolapAggregator aggregator;

private Measure(
public Measure(
String name,
String cubeName,
RolapAggregator aggregator,
Expand Down

0 comments on commit 5782451

Please sign in to comment.