Skip to content

Commit

Permalink
MONDRIAN: fixed problem with DB2 - must use FLOAT to get the right nu…
Browse files Browse the repository at this point in the history
…mbers

[git-p4: depot-paths = "//open/mondrian/": change = 4563]
  • Loading branch information
Andreas Voss committed Dec 2, 2005
1 parent 56e91d4 commit 01325a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/main/mondrian/rolap/RolapNativeSql.java
Expand Up @@ -30,6 +30,8 @@
public class RolapNativeSql {

private SqlQuery sqlQuery;
private SqlQuery.Dialect dialect;

CompositeSqlCompiler numericCompiler;
CompositeSqlCompiler booleanCompiler;

Expand Down Expand Up @@ -85,7 +87,11 @@ public String compile(Exp exp) {
if ((exp.getCategory() & Category.Numeric) == 0)
return null;
Literal literal = (Literal) exp;
return String.valueOf(literal.getValue());
String expr = String.valueOf(literal.getValue());
if (dialect.isDB2()) {
expr = "FLOAT(" + expr + ")";
}
return expr;
}

public String toString() {
Expand Down Expand Up @@ -126,7 +132,11 @@ public String compile(Exp exp) {
RolapStoredMeasure measure = (RolapStoredMeasure) exp;
if (measure.isCalculated()) { return null; } // ??
String exprInner = measure.getMondrianDefExpression().getExpression(sqlQuery);
return measure.getAggregator().getExpression(exprInner);
String expr = measure.getAggregator().getExpression(exprInner);
if (dialect.isDB2()) {
expr = "FLOAT(" + expr + ")";
}
return expr;
}

public String toString() {
Expand Down Expand Up @@ -345,6 +355,8 @@ public String compile(Exp exp) {
*/
RolapNativeSql(SqlQuery sqlQuery) {
this.sqlQuery = sqlQuery;
this.dialect = sqlQuery.getDialect();

numericCompiler = new CompositeSqlCompiler();
booleanCompiler = new CompositeSqlCompiler();

Expand Down
2 changes: 1 addition & 1 deletion src/main/mondrian/rolap/RolapNativeTopCount.java
Expand Up @@ -58,7 +58,7 @@ protected boolean isJoinRequired() {
public void addConstraint(SqlQuery sqlQuery) {
if (orderByExpr != null) {
Dialect dialect = sqlQuery.getDialect();
if (dialect.isMySQL()) {
if (dialect.isMySQL() || dialect.isDB2()) {
String alias = sqlQuery.nextColumnAlias();
alias = dialect.quoteIdentifier(alias);
sqlQuery.addSelect(orderByExpr, alias);
Expand Down

0 comments on commit 01325a6

Please sign in to comment.