Skip to content

Commit

Permalink
MONDRIAN: Fix bug 1953480, "Need support for qualified function names…
Browse files Browse the repository at this point in the history
…". Parser now parses them, but ignores all but last identifier.

[git-p4: depot-paths = "//open/mondrian/": change = 10991]
  • Loading branch information
julianhyde committed May 1, 2008
1 parent a03504f commit 37e0539
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
15 changes: 13 additions & 2 deletions src/main/mondrian/olap/Parser.cup
Expand Up @@ -315,6 +315,7 @@ terminal
// b. Symbols
terminal
ASTERISK, // *
BANG, // !
COLON, // :
COMMA, // ,
CONCAT, // ||
Expand Down Expand Up @@ -365,6 +366,7 @@ non terminal QueryPart
select_statement,
statement;
non terminal Id
bang_compound_id,
compound_id,
cube_name,
cube_specification,
Expand Down Expand Up @@ -471,7 +473,15 @@ compound_id ::=
| compound_id:hd DOT identifier:tl {:
RESULT = hd.append(tl);
:}
;

bang_compound_id ::=
identifier:i {:
RESULT = new Id(i);
:}
| bang_compound_id:hd BANG identifier:tl {:
RESULT = hd.append(tl);
:}
;

//
Expand Down Expand Up @@ -833,9 +843,10 @@ value_expression_primary ::=
RESULT = new UnresolvedFunCall(
j.name, Syntax.Method, Parser.toExpArray(lis));
:}
| identifier:i LPAREN exp_list_opt:lis RPAREN {:
| bang_compound_id:i LPAREN exp_list_opt:lis RPAREN {:
RESULT = new UnresolvedFunCall(
i.name, Syntax.Function, Parser.toExpArray(lis));
i.getSegments().get(i.getSegments().size() - 1).name,
Syntax.Function, Parser.toExpArray(lis));
:}
| CAST LPAREN expression:e AS identifier:t RPAREN {:
RESULT = new UnresolvedFunCall(
Expand Down
1 change: 1 addition & 0 deletions src/main/mondrian/olap/Scanner.java
Expand Up @@ -718,6 +718,7 @@ public Symbol next_token() throws IOException {
case '-': advance(); return makeToken(ParserSym.MINUS, "-");
case '*': advance(); return makeToken(ParserSym.ASTERISK, "*");
case '/': advance(); return makeToken(ParserSym.SOLIDUS, "/");
case '!': advance(); return makeToken(ParserSym.BANG, "!");
case '|':
advance();
switch (nextChar) {
Expand Down
20 changes: 7 additions & 13 deletions testsrc/main/mondrian/olap/ParserTest.java
Expand Up @@ -297,6 +297,13 @@ public void testCast() {
"CAST((1.0 + 2.0) AS String)");
}

public void testBangFunction() {
// Parser accepts '<id> [! <id>] *' as a function name, but ignores
// all but last name.
assertParseExpr("foo!bar!Exp(2.0)", "Exp(2.0)");
assertParseExpr("1 + VBA!Exp(2.0 + 3)", "(1.0 + Exp((2.0 + 3.0)))");
}

public void testId() {
assertParseExpr("foo", "foo");
assertParseExpr("fOo", "fOo");
Expand Down Expand Up @@ -537,19 +544,6 @@ private void unparse(PrintWriter pw) {
}
}
}

/**
* Converts an expression to a string.
*
* @param exp Expression
* @return Expression converted to a string
*/
public String toMdxString(Exp exp) {
StringWriter sw = new StringWriter();
PrintWriter pw = new QueryPrintWriter(sw);
unparse(pw);
return sw.toString();
}
}
}

Expand Down

0 comments on commit 37e0539

Please sign in to comment.