Skip to content

Metric Parameter (Spider)

Randy Guck edited this page Sep 26, 2014 · 3 revisions

[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 all Tags 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 the Size field, whereas DISTINCT(Size) finds the number of unique Size values.

  • SUM(field): Sums the non-null values for the given numeric field. The field’s type must be integer, long, float, or double.

  • AVERAGE(field): Computes the average value for the given field, which must be integer, long, float, double, or timestamp. Note that the AVERAGE 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 computes AVERAGE(foo) for four selected objects, whose value for foo 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.

Clone this wiki locally