Skip to content

Commit

Permalink
MONDRIAN: Integrate from mondrian-release/3.1@13180.
Browse files Browse the repository at this point in the history
[git-p4: depot-paths = "//open/mondrian/": change = 13181]
  • Loading branch information
julianhyde committed Nov 23, 2009
1 parent 90f1e5e commit f9db631
Show file tree
Hide file tree
Showing 54 changed files with 1,733 additions and 253 deletions.
3 changes: 3 additions & 0 deletions src/main/mondrian/calc/impl/AbstractExpCompiler.java
Expand Up @@ -120,6 +120,8 @@ public Calc compileAs(
return compileHierarchy(exp);
} else if (resultType instanceof DimensionType) {
return compileDimension(exp);
} else if (resultType instanceof ScalarType) {
return compileScalar(exp, false);
}
}
final Calc calc = compile(exp);
Expand Down Expand Up @@ -292,6 +294,7 @@ public ListCalc compileList(Exp exp) {
}

public ListCalc compileList(Exp exp, boolean mutable) {
assert exp.getType() instanceof SetType : "must be a set: " + exp;
final List<ResultStyle> resultStyleList;
if (mutable) {
resultStyleList = ResultStyle.MUTABLELIST_ONLY;
Expand Down
3 changes: 1 addition & 2 deletions src/main/mondrian/mdx/NamedSetExpr.java
Expand Up @@ -133,8 +133,7 @@ public boolean dependsOn(Hierarchy hierarchy) {
}

public Evaluator.NamedSetEvaluator getEval(Evaluator evaluator) {
return evaluator.getNamedSetEvaluator(
namedSet.getName(), namedSet.getExp());
return evaluator.getNamedSetEvaluator(namedSet, true);
}

public Object accept(MdxVisitor visitor) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/mondrian/olap/DelegatingSchemaReader.java
Expand Up @@ -44,6 +44,10 @@ public Role getRole() {
return schemaReader.getRole();
}

public Cube getCube() {
return schemaReader.getCube();
}

public List<Dimension> getCubeDimensions(Cube cube) {
return schemaReader.getCubeDimensions(cube);
}
Expand Down Expand Up @@ -227,6 +231,10 @@ public Parameter getParameter(String name) {
public DataSource getDataSource() {
return schemaReader.getDataSource();
}

public SchemaReader withoutAccessControl() {
return schemaReader.withoutAccessControl();
}
}

// End DelegatingSchemaReader.java
6 changes: 3 additions & 3 deletions src/main/mondrian/olap/Evaluator.java
Expand Up @@ -213,11 +213,11 @@ public interface Evaluator {
/**
* Returns an evaluator for a named set.
*
* @param name Name of set
* @param exp Expression to compute named set
* @param namedSet Named set
* @param create Whether to create evaluator if not found
* @return Evaluator of named set
*/
NamedSetEvaluator getNamedSetEvaluator(String name, Exp exp);
NamedSetEvaluator getNamedSetEvaluator(NamedSet namedSet, boolean create);

/**
* Returns an array of the members which make up the current context.
Expand Down
5 changes: 2 additions & 3 deletions src/main/mondrian/olap/Formula.java
Expand Up @@ -65,7 +65,7 @@ public Formula(
this(true, id, exp, memberProperties, null, null);
}

private Formula(
Formula(
boolean isMember,
Id id,
Exp exp,
Expand Down Expand Up @@ -206,7 +206,7 @@ void createElement(Query q) {
Util.assertTrue(
id.getSegments().size() == 1,
"set names must not be compound");
mdxSet = new SetBase(id.getSegments().get(0).name, exp);
mdxSet = new SetBase(id.getSegments().get(0).name, exp, false);
}
}

Expand All @@ -219,7 +219,6 @@ public Object[] getChildren() {
return children;
}


public void unparse(PrintWriter pw)
{
if (isMember) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/mondrian/olap/Id.java
Expand Up @@ -106,7 +106,8 @@ public Exp accept(Validator validator) {
}
final Exp element =
Util.lookup(
validator.getQuery(), segments, true);
validator.getQuery(), validator.getSchemaReader(), segments,
true);

if (element == null) {
return null;
Expand Down
24 changes: 24 additions & 0 deletions src/main/mondrian/olap/NamedSet.java
Expand Up @@ -41,6 +41,30 @@ public interface NamedSet extends OlapElement {
Exp getExp();

NamedSet validate(Validator validator);

/**
* Returns a name for this set that is unique within the query.
*
* <p>This is necessary when there are several 'AS' expressions, or an 'AS'
* expression overrides a named set defined using 'WITH MEMBER' clause or
* against a cube.
*/
String getNameUniqueWithinQuery();

/**
* Returns whether this named set is dynamic.
*
* <p>Evaluation rules:
* <ul>
* <li>A dynamic set is evaluated each time it is used, and inherits the
* context in which it is evaluated.
* <li>A static set is evaluated only on first use, in the base context of
* the cube.
* </ul>
*
* @return Whether this named set is dynamic
*/
boolean isDynamic();
}

// End NamedSet.java
20 changes: 19 additions & 1 deletion src/main/mondrian/olap/Parser.cup
Expand Up @@ -359,6 +359,8 @@ terminal String UNKNOWN; // a token the lexer doesn't like!
// Non terminals
non terminal QueryAxis
axis_specification;
non terminal UnresolvedFunCall
aliasedExpression;
non terminal Exp
case_expression,
else_clause_opt,
Expand Down Expand Up @@ -881,7 +883,10 @@ value_expression_primary ::=
i.getSegments().get(i.getSegments().size() - 1).name,
Syntax.Function, Parser.toExpArray(lis));
:}
| CAST LPAREN expression:e AS identifier:t RPAREN {:
| CAST LPAREN aliasedExpression:ae RPAREN {:
assert ae.getArgCount() == 2;
Exp e = ae.getArg(0);
Id.Segment t = ((Id) ae.getArg(1)).getSegments().get(0);
RESULT = new UnresolvedFunCall(
"CAST", Syntax.Cast, new Exp[] {
e,
Expand Down Expand Up @@ -1222,20 +1227,24 @@ expression ::=
expression:x COLON value_expression:y {: // range yields set
RESULT = new UnresolvedFunCall(":", Syntax.Infix, new Exp[] {x, y});
:}
| aliasedExpression
| value_expression
;

expression_or_empty ::=
expression
| /* empty */ {:
RESULT = new UnresolvedFunCall("", Syntax.Empty, new Exp[] {});
:}
;

exp_list_opt ::=
/* empty */ {:
RESULT = new LinkedList();
:}
| exp_list
;

exp_list ::=
expression:e {:
RESULT = new LinkedList();
Expand All @@ -1245,6 +1254,15 @@ exp_list ::=
list.add(0, e); RESULT = list;
:}
;

aliasedExpression ::=
expression:x AS identifier:i {:
Id id = new Id(i);
RESULT =
new UnresolvedFunCall("AS", Syntax.Infix, new Exp[] {x, id});
:}
;

//
// Leveling Rules for Member Value Expression
//
Expand Down

0 comments on commit f9db631

Please sign in to comment.