# Functions

## metric-hub

Pre-defined functions that can be used in select expressions across all metrics and segment definitions. These functions are defined in metric-hub

### agg_sum

Sum

Calculates the sum of the select expression

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55437520>, definition='COALESCE(SUM({select_expr}), 0)')
``````

### agg_any

Any

Returns true if any of the boolean selected values are TRUE, otherwise FALSE

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf554376d0>, definition='COALESCE(LOGICAL_OR({select_expr}), FALSE)')
``````

### agg_histogram_mean

Histogram Mean

Computes the mean of the histogram

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55437640>, definition='    SAFE_DIVIDE(\n        SUM(CAST(JSON_EXTRACT_SCALAR({select_expr}, "\$.sum") AS int64)),\n        SUM((SELECT SUM(value) FROM UNNEST(mozfun.hist.extract({select_expr}).values)))\n    )\n')
``````

### agg_hist_zero_fract

Histogram Zero Fraction

Computes the fraction of entries in a Histogram which are zero

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55437490>, definition='    SAFE_DIVIDE(\n        SUM(mozfun.map.get_key(mozfun.hist.extract({select_expr}).values,0)),\n        SUM(mozfun.hist.threshold_count({select_expr},1))\n    )\n')
``````

## jetstream-config

Pre-defined functions that can be used in select expressions across all metrics and segment definitions. These functions are defined in jetstream-config

### agg_sum

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55494f70>, definition='COALESCE(SUM({select_expr}), 0)')
``````

### agg_any

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55494ca0>, definition='COALESCE(LOGICAL_OR({select_expr}), FALSE)')
``````

### agg_histogram_mean

Definition:
``````functools.partial(<function FunctionsSpec.from_dict.<locals>.<dictcomp>.<lambda> at 0x7faf55495f30>, definition='    SAFE_DIVIDE(\n        SUM(CAST(JSON_EXTRACT_SCALAR({select_expr}, "\$.sum") AS int64)),\n        SUM((SELECT SUM(value) FROM UNNEST(mozfun.hist.extract({select_expr}).values)))\n    )\n')
``````