Skip to content

Commit

Permalink
MONDRIAN: Prevents Mondrian from doing a raw-data rollup using the di…
Browse files Browse the repository at this point in the history
…stinct-count aggregator. We can't rollup from raw data for distinct count measures because this would only sum up the distinct counts and gives invalid results.

[git-p4: depot-paths = "//open/mondrian/": change = 14928]
  • Loading branch information
lucboudreau committed Feb 6, 2012
1 parent 8f18559 commit c3e8ec9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/mondrian/rolap/FastBatchingCellReader.java
Expand Up @@ -598,7 +598,15 @@ private void recordCellRequest2(final CellRequest request) {
// with the same target dimensionality. It is quite likely that the
// other rollup will satisfy this request, and it's complicated to be
// 100% sure. If we're wrong, we'll be back.
if (measure.getAggregator().getRollup().supportsFastAggregates(

// Also make sure that we don't try to rollup a measure which
// doesn't support rollup from raw data, like a distinct count
// for example. Both the measure's aggregator and its rollup
// aggregator must support raw data aggregation. We call
// Aggregator.supportsFastAggregates() to verify.
if (measure.getAggregator().supportsFastAggregates(
measure.getDatatype())
&& measure.getAggregator().getRollup().supportsFastAggregates(
measure.getDatatype())
&& !rollupBitmaps.contains(request.getConstrainedColumnsBitKey()))
{
Expand Down
8 changes: 8 additions & 0 deletions src/main/mondrian/rolap/RolapAggregator.java
Expand Up @@ -214,6 +214,14 @@ public Object aggregate(
public String getExpression(String operand) {
return "count(distinct " + operand + ")";
}

public boolean supportsFastAggregates(
mondrian.spi.Dialect.Datatype dataType)
{
// We can't rollup using the raw data, because this is
// a distinct-count operation.
return false;
};
};

/**
Expand Down

0 comments on commit c3e8ec9

Please sign in to comment.