Skip to content

Commit

Permalink
MONDRIAN: Add CountDistinct aggregation function;
Browse files Browse the repository at this point in the history
implement '*' alternative syntax for CrossJoin.

[git-p4: depot-paths = "//open/mondrian/": change = 643]
  • Loading branch information
julianhyde committed Jul 9, 2003
1 parent 6c4708a commit 7263680
Show file tree
Hide file tree
Showing 15 changed files with 817 additions and 298 deletions.
9 changes: 4 additions & 5 deletions demo/FoodMart.xml
Expand Up @@ -11,7 +11,6 @@
==
== todo:
== 1. <CalculatedMember/>
== 2. <Measure aggregator="distinct count"/>
-->

<!-- Shared dimensions -->
Expand Down Expand Up @@ -187,6 +186,7 @@ CONCAT(`customer`.`fname`, " ", `customer`.`lname`)
<!--
<Measure name="Store Sales Net" column="&quot;sales_fact_1997&quot;.&quot;store_sales&quot;-&quot;sales_fact_1997&quot;.&quot;store_cost&quot;" aggregator="sum" formatString="#,###.00"/>
-->
<Measure name="Customer Count" column="customer_id" aggregator="distinct count" formatString="#,###"/>
</Cube>

<Cube name="Warehouse">
Expand Down Expand Up @@ -280,10 +280,10 @@ CONCAT(`customer`.`fname`, " ", `customer`.`lname`)
</Dimension>
<DimensionUsage name="Store Type" source="Store Type" foreignKey="store_id"/>
<Dimension name="Position" foreignKey="employee_id">
<Hierarchy hasAll="true" primaryKey="employee_id">
<Hierarchy hasAll="true" allMemberName="All Position" primaryKey="employee_id">
<Table name="employee"/>
<Level name="Management Role" uniqueMembers="true" column="management_role"/>
<Level name="Position Title" uniqueMembers="false" column="position_title"/>
<Level name="Position Title" uniqueMembers="false" column="position_title" ordinalColumn="position_id"/>
</Hierarchy>
</Dimension>
<Dimension name="Department" foreignKey="department_id">
Expand All @@ -307,8 +307,7 @@ CONCAT(`customer`.`fname`, " ", `customer`.`lname`)
</Dimension>
<Measure name="Org Salary" column="salary_paid" aggregator="sum" formatString="Currency" />
<Measure name="Count" column="employee_id" aggregator="count" formatString="#,#"/>
<!-- todo: change aggregator="distinct count"-->
<Measure name="Number of Employees" column="employee_id" aggregator="count" formatString="#,#"/>
<Measure name="Number of Employees" column="employee_id" aggregator="distinct count" formatString="#,#"/>
<CalculatedMember name="Employee Salary" dimension="[Measures]" formatString="Currency"
formula="(employees.currentmember.datamember, [Measures].[Org Salary])"/>
<CalculatedMember name="Avg Salary" dimension="[Measures]" formatString="Currency"
Expand Down
37 changes: 37 additions & 0 deletions src/main/mondrian/olap/Aggregator.java
@@ -0,0 +1,37 @@
/*
// $Id$
// This software is subject to the terms of the Common Public License
// Agreement, available at the following URL:
// http://www.opensource.org/licenses/cpl.html.
// Copyright (C) 2003-2003 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
package mondrian.olap;

import java.util.List;

/**
* Describes an aggregation operator, such as "sum" or "count".
*
* @see FunDef
* @see Evaluator
*
* @author jhyde$
* @since Jul 9, 2003$
* @version $Id$
**/
public interface Aggregator {
/**
* Returns the aggregator used to combine sub-totals into a grand-total.
*/
Aggregator getRollup();

/**
* Applies this aggregator to an expression over a set of members and
* returns the result.
*/
Object aggregate(Evaluator evaluator, List members, Exp exp);
}

// End Aggregator.java
1 change: 1 addition & 0 deletions src/main/mondrian/olap/Mondrian.xml
Expand Up @@ -430,6 +430,7 @@ todo:
<Value>min</Value>
<Value>max</Value>
<Value>avg</Value>
<Value>distinct count</Value>
</Attribute>
</Element>

Expand Down
3 changes: 3 additions & 0 deletions src/main/mondrian/olap/Parser.cup
Expand Up @@ -1206,6 +1206,9 @@ property_list ::=
property
| property COMMA property_list
;
property ::=
compound_id
;
//
// <cube_specification> ::= [<cube_name>] [, <cube_name>]
// jhyde: In this implementation, you must supply EXACTLY one cube.
Expand Down

0 comments on commit 7263680

Please sign in to comment.