-
Notifications
You must be signed in to change notification settings - Fork 22
Metric Parameter (Spider)
[Table of Contents](https://github.com/dell-oss/Doradus/wiki/Spider Databases: Table-of-Contents) | Previous | Next
Spider Aggregate Queries: Metric Parameter Overview
The metric parameter is a comma-separated list of *metric functions*. Each function performs a statistical calculation on a scalar or link field. The general syntax of a metric function is:
function(field)
Where function is a metric function name and field defines what the metric function is computed on. The field must be a scalar or link defined in the application’s schema. It can belong to the perspective table, or it can be a path to a field linked to the perspective table (e.g., DirectReports.Name
). The supported metric functions are summarized below:
-
COUNT(field)
: Counts the values for the specified field. If the field is multi-valued with respect to the perspective object, all values are counted for each selected object. For example,COUNT(Tags)
tallies allTags
values of all objects. The COUNT function also allows the special value "*
", which counts the selected objects in the perspective table regardless of any fields. That is,COUNT(*)
counts objects instead of values. -
DISTINCT(field)
: This metric is similar to COUNT except that it totals unique values for the given field. For example,COUNT(Size)
finds the total number of values of theSize
field, whereasDISTINCT(Size)
finds the number of uniqueSize
values. -
SUM(field)
: Sums the non-null values for the given numeric field. The field’s type must beinteger
,long
,float
, ordouble
. -
AVERAGE(field)
: Computes the average value for the given field, which must beinteger
,long
,float
,double
, ortimestamp
. Note that theAVERAGE
function uses SQL null-elimination semantics. This means that objects for which the metric field does not have a value are not considered for computation even though the object itself was selected. As an example, consider an aggregate query that computesAVERAGE(foo)
for four selected objects, whose value forfoo
are 2, 4, 6, and null. The value computed will be 4 ((2+4+6)/3) not 3 ((2+4+6+0)/4) because the object with the null field is eliminated from the computation. -
MIN(field)
: Computes the minimum value for the given field. For scalar fields,MIN
computes the lowest value found based on the field type’s natural order. For link fields,MIN
computes the lowest object ID found in the link field’s values based on the string form of the object ID. -
MAX(field)
: Computes the maximum value for the given field, which must be a predefined scalar or link field.
Example metric functions are shown below:
COUNT(*)
DISTINCT(Tags)
MAX(Sender.Person.LastName)
AVERAGE(Size)
MAXCOUNT(Sender.Person.DirectReports)
The metric parameter can be a comma-separated list of metric functions. All functions are computed concurrently as objects are selected. An example metric parameter with multiple functions is shown below:
MIN(Size),MAX(Size),COUNT(InternalRecipients)
The results of multi-metric aggregate queries are described later.
Technical Documentation
[Doradus OLAP Databases](https://github.com/dell-oss/Doradus/wiki/Doradus OLAP Databases)
- Architecture
- OLAP Database Overview
- OLAP Data Model
- Doradus Query Language (DQL)
- OLAP Object Queries
- OLAP Aggregate Queries
- OLAP REST Commands
- Architecture
- Spider Database Overview
- Spider Data Model
- Doradus Query Language (DQL)
- Spider Object Queries
- Spider Aggregate Queries
- Spider REST Commands
- [Installing and Running Doradus](https://github.com/dell-oss/Doradus/wiki/Installing and Running Doradus)
- [Deployment Guidelines](https://github.com/dell-oss/Doradus/wiki/Deployment Guidelines)
- [Doradus Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Doradus Configuration and Operation)
- [Cassandra Configuration and Operation](https://github.com/dell-oss/Doradus/wiki/Cassandra Configuration and Operation)