Aggregation
The
Aggregation module facilitates creation of statically typed functional data Expression's, as well as providing a set of standard libraries for common Expression patterns.Aggregation
AggregationDefinition
Ƭ AggregationDefinition<T
>:
CustomAggregationDefinition
<T
> | StandardAggregationDefinition
<T
>
A
AggregationDefinition is either a CustomAggregationDefinition or StandardAggregationDefinition.Type parameters
Name | Type |
---|---|
T | extends EastType = EastType |
CustomAggregationDefinition
Ƭ CustomAggregationDefinition<T
, U
>: Object
An
CustomAggregationDefinition represents a reduction over rows followed by an optional final transformation.Type parameters
Name | Type |
---|---|
T | extends EastType = EastType |
U | extends EastType = EastType |
Type declaration
Name | Type |
---|---|
aggregation_type | "Custom" |
finalizer | EastFunction <T > |
initial | EastFunction <U > |
inverse_reducer | EastFunction <U > |
previous | Variable <U > |
reducer | EastFunction <U > |
type | T |
StandardAggregationDefinition
Ƭ StandardAggregationDefinition<T
, U
>: Object
A
StandardAggregationDefinition calculates one of a handful of built-in reductions over rows.Type parameters
Name | Type |
---|---|
T | extends EastType = EastType |
U | extends StandardAggregationType = StandardAggregationType |
Type declaration
Name | Type |
---|---|
aggregation_type | U |
key? | EastFunction |
type | T |
value | EastFunction |
Any
▸ Any(value
):
StandardAggregationDefinition
<BooleanType
>
Create an
AggregationDefinition that returns true if one or more value istrue
.
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <BooleanType > | the value to aggregate |
Returns
StandardAggregationDefinition
<BooleanType
>
the
Any StandardAggregationDefinitionExample
// ...
aggregations: {
// return true if a category value is null
CategoryMissing: fields => Any(IsNull(fields.Category)),
// ...
}
CollectDict
▸ CollectDict<K
, T
>(key
, value
):
StandardAggregationDefinition
<DictType
<K
, T
>>
Create an
AggregationDefinition to create a dictionary of distinct key-value pairs. If multiple distinct, non-null values exist for a given key, then the value isnull
for that key.
Type parameters
Name | Type |
---|---|
K | extends StringType |
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
key | EastFunction <K > | the dict key value |
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<DictType
<K
, T
>>
the
CollectDict StandardAggregationDefinitionExample
// ...
aggregations: {
// collect all non-null HourlyRate's into a dictionary by EmployeeId
HourlyRatePerEmployee: fields => CollectDict(
fields.EmployeeId,
fields.HourlyRate
),
// ...
}
CollectDictCount
▸ CollectDictCount(value
):
StandardAggregationDefinition
<DictType
<StringType
, IntegerType
>>
Create an
AggregationDefinition to create a dictionary of the count of non-null keysParameters
Name | Type | Description |
---|---|---|
value | EastFunction <StringType > | the dict key value |
Returns
StandardAggregationDefinition
<DictType
<StringType
, IntegerType
>>
the
CollectDictCount StandardAggregationDefinitionExample
// ...
aggregations: {
// create a dictionary with the count of products by Category
ProductsPerCategory: fields => CollectDictCount(
fields.Category,
),
// ...
}
CollectDictMax
▸ CollectDictMax<T
>(key
, value
):
StandardAggregationDefinition
<DictType
<StringType
, T
>>
Create an
AggregationDefinition to create a dictionary of the maximum of non-null values for key-value pairs.Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
key | EastFunction <StringType > | the dict key value |
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<DictType
<StringType
, T
>>
the
CollectDictMean StandardAggregationDefinitionExample
// ...
aggregations: {
// create a dictionary with the min of Price per Category
MaxPricePerCategory: fields => CollectDictMax(
fields.Category,
fields.Price
),
// ...
}
CollectDictMean
▸ CollectDictMean(key
, value
):
StandardAggregationDefinition
<DictType
<StringType
, FloatType
>>
Create an
AggregationDefinition to create a dictionary of the sum of non-null values for key-value pairs.Parameters
Name | Type | Description |
---|---|---|
key | EastFunction <StringType > | the dict key value |
value | EastFunction <IntegerType | FloatType > | the value to aggregate |
Returns
StandardAggregationDefinition
<DictType
<StringType
, FloatType
>>
the
CollectDictMean StandardAggregationDefinitionExample
// ...
aggregations: {
// create a dictionary with the average of Price per Category
MeanPricePerCategory: fields => CollectDictMean(
fields.Category,
fields.Price
),
// ...
}
CollectDictMin
▸ CollectDictMin<T
>(key
, value
):
StandardAggregationDefinition
<DictType
<StringType
, T
>>
Create an
AggregationDefinition to create a dictionary of the minimum of non-null values for key-value pairs.Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
key | EastFunction <StringType > | the dict key value |
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<DictType
<StringType
, T
>>
the
CollectDictMean StandardAggregationDefinitionExample
// ...
aggregations: {
// create a dictionary with the min of Price per Category
MinPricePerCategory: fields => CollectDictMin(
fields.Category,
fields.Price
),
// ...
}
CollectDictSum
▸ CollectDictSum<T
>(key
, value
): T
extends
NullType
? StandardAggregationDefinition
<DictType
<StringType
, NonNullable
<T
>>> : StandardAggregationDefinition
<DictType
<StringType
, T
>>
Create an
AggregationDefinition to create a dictionary of the sum of non-null values for key-value pairs.Type parameters
Name | Type |
---|---|
T | extends IntegerType | FloatType |
Parameters
Name | Type | Description |
---|---|---|
key | EastFunction <StringType > | the dict key value |
value | EastFunction <T > | the value to aggregate |
Returns
T
extends
NullType
? StandardAggregationDefinition
<DictType
<StringType
, NonNullable
<T
>>> : StandardAggregationDefinition
<DictType
<StringType
, T
>>
the
CollectDictSum StandardAggregationDefinitionExample
// ...
aggregations: {
// create a dictionary with the sum of Qty's by Category
QtyPerCategory: fields => CollectDictSum(
fields.Category,
fields.Qty
),
// ...
}
CollectSet
▸ CollectSet<K
>(value
):
StandardAggregationDefinition
<SetType
<K
>>
Create an
AggregationDefinition to find the set of the non-null string values ofvalue
(which defaults to field
).
Type parameters
Name | Type |
---|---|
K | extends StringType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <K > | the value to aggregate |
Returns
StandardAggregationDefinition
<SetType
<K
>>
the
CollectSet StandardAggregationDefinitionExample
// ...
aggregations: {
// collect all non-null Categorie's into a set
Categories: fields => CollectSet(fields.Category),
// ...
}
Count
▸ Count(value?
):
StandardAggregationDefinition
<IntegerType
>
Create an Aggregation
to count the number of rows where value
is not null.
Parameters
Name | Type | Description |
---|---|---|
value? | EastFunction | the value to aggregate |
Returns
StandardAggregationDefinition
<IntegerType
>
the
Count StandardAggregationDefinitionExample
// ...
aggregations: {
// count the number of Category's that aren't null
ValidCategories: fields => Count(fields.Category),
// ...
}
DistinctCount
▸ DistinctCount(value
):
StandardAggregationDefinition
<IntegerType
>
Create an Aggregation
to count the number of distinct, non-null values of value
.
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction | the value to aggregate |
Returns
StandardAggregationDefinition
<IntegerType
>
the
DistinctCount StandardAggregationDefinitionExample
// ...
aggregations: {
// count the number of distinct non-null Category's
Categories: fields => DistinctCount(fields.Category),
// ...
}
Every
▸ Every(value
):
StandardAggregationDefinition
<BooleanType
>
Create an
AggregationDefinition that returns true if all values aretrue
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <BooleanType > | the value to aggregate |
Returns
StandardAggregationDefinition
<BooleanType
>
the
Every StandardAggregationDefinitionExample
// ...
aggregations: {
// return true if all category values are null
AllCategoriesMissing: fields => Every(
IsNull(fields.Category)
),
// ...
}
FindMaximum
▸ FindMaximum<K
, T
>(value
, key
): K
extends
NullType
? T
extends NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>> : StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the value ofkey
, in the key-value pair that has the largest, non-null value of value
(which defaults to field
).
Type parameters
Name | Type |
---|---|
K | extends EastType |
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <K > | the value to aggregate |
key | EastFunction <T > | the value to find the minimum of |
Returns
K
extends
NullType
? T
extends NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>> : StandardAggregationDefinition
<T
>
the
FindMaximum StandardAggregationDefinitionExample
// ...
aggregations: {
// return Product with the lowest Price
HighestPriceProduct: fields => FindMaximum(
fields.Price,
fields.Product
),
// ...
}
FindMinimum
▸ FindMinimum<K
, T
>(value
, key
): K
extends
NullType
? T
extends NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>> : StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the value ofkey
, in the key-value pair that has the smallest, non-null value of value
(which defaults to field
).
Type parameters
Name | Type |
---|---|
K | extends EastType |
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <K > | the value to aggregate |
key | EastFunction <T > | the value to find the minimum of |
Returns
K
extends
NullType
? T
extends NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>> : StandardAggregationDefinition
<T
>
the
FindMinimum StandardAggregationDefinitionExample
// ...
aggregations: {
// return Product with the lowest Price
LowestPriceProduct: fields => FindMinimum(
fields.Price,
fields.Product
),
// ...
}
Maximum
▸ Maximum<T
>(value
):
StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the largest, non-null value ofvalue
(which defaults to field
).
Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<T
>
the
Maximum StandardAggregationDefinitionExample
// ...
aggregations: {
// return the highest Price
MaxPrice: fields => Maximum(fields.Price),
// ...
}
Mean
▸ Mean(value
):
StandardAggregationDefinition
<FloatType
>
Create an
AggregationDefinition to find the mean of the non-null values ofvalue
(which defaults to field
).
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <IntegerType | FloatType > | the value to aggregate |
Returns
StandardAggregationDefinition
<FloatType
>
the
Mean StandardAggregationDefinitionExample
// ...
aggregations: {
// find the mean Qty's
MeanQty: fields => Mean(fields.Qty),
// ...
}
Median
▸ Median<T
>(value
):
StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the median of the non-null values ofvalue
(which defaults to field
). In case of a tie, the greater number is returned.
Type parameters
Name | Type |
---|---|
T | extends IntegerType | FloatType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<T
>
the
Median StandardAggregationDefinitionExample
// ...
aggregations: {
// return the middle Price
MedianPrice: fields => Median(fields.Price),
// ...
}
Minimum
▸ Minimum<T
>(value
):
StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the smallest, non-null value ofvalue
(which defaults to field
).
Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<T
>
the
Minimum StandardAggregationDefinitionExample
// ...
aggregations: {
// return the lowest Price
MinPrice: fields => Minimum(fields.Price),
// ...
}
Mode
▸ Mode<T
>(value
):
StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the most common, non-null value ofvalue
(which defaults to field
). If a tie is encountered, any one of the most-common values is chosen.
Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<T
>
the
Mode StandardAggregationDefinitionExample
// ...
aggregations: {
// return the mode of prices
ModalPrice: fields => Mode(fields.Price),
// ...
}
Span
▸ Span<T
>(value
):
StandardAggregationDefinition
<T
>
Create an
AggregationDefinition to find the span of the non-null values ofvalue
(which defaults to field
), meaning the difference between the largest and smallest values.
Type parameters
Name | Type |
---|---|
T | extends IntegerType | FloatType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
StandardAggregationDefinition
<T
>
the
Span StandardAggregationDefinitionExample
// ...
aggregations: {
// return the Price span
PriceSpan: fields => Span(fields.Price),
// ...
}
SparseDictCovariance
▸ SparseDictCovariance(value_expr
):
AggregationDefinition
<DictType
<StringType
, DictType
<StringType
, FloatType
>>>
Create an
AggregationDefinition to calculate the covariance of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.Parameters
Name | Type | Description |
---|---|---|
value_expr | Expression <DictType <StringType , FloatType >> | the value to aggregate |
Returns
AggregationDefinition
<DictType
<StringType
, DictType
<StringType
, FloatType
>>>
the
SparseDictMean CustomAggregationDefinitionExample
// ...
aggregations: {
// return the ...
PriceCardCoVariance: fields => SparseDictCovariance(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}
SparseDictMean
▸ SparseDictMean(value_expr
):
AggregationDefinition
<DictType
<StringType
, FloatType
>>
Create an
AggregationDefinition to calculate the average values of a "sparse" dictionary where missing elements are presumed to have value of zero.Parameters
Name | Type | Description |
---|---|---|
value_expr | Expression <DictType <StringType , IntegerType >> | the value to aggregate |
Returns
AggregationDefinition
<DictType
<StringType
, FloatType
>>
the
SparseDictMean CustomAggregationDefinitionExample
// ...
aggregations: {
// return the ...
PriceCardAvg: fields => SparseDictMean(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}
SparseDictSum
▸ SparseDictSum(value_expr
):
AggregationDefinition
<DictType
<StringType
, FloatType
>>
Create an
AggregationDefinition to calculate the sum of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.Parameters
Name | Type | Description |
---|---|---|
value_expr | Expression <DictType <StringType , FloatType >> | the value to aggregate |
Returns
AggregationDefinition
<DictType
<StringType
, FloatType
>>
the
SparseDictSum CustomAggregationDefinitionExample
// ...
aggregations: {
// return the ...
PriceCardTotal: fields => SparseDictSum(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}
SparseDictVariance
▸ SparseDictVariance(value_expr
):
AggregationDefinition
<DictType
<StringType
, FloatType
>>
Create an
AggregationDefinition to calculate the variance of the values of a "sparse" dictionary where missing elements are presumed to have value of zero.Parameters
Name | Type | Description |
---|---|---|
value_expr | Expression <DictType <StringType , FloatType >> | the value to aggregate |
Returns
AggregationDefinition
<DictType
<StringType
, FloatType
>>
the
SparseDictMean CustomAggregationDefinitionExample
// ...
aggregations: {
// return the ...
PriceCardVariance: fields => SparseDictVariance(fields.PriceCard, DictType(StringType,FloatType))),
// ...
}
StdDev
▸ StdDev(value
):
StandardAggregationDefinition
<FloatType
>
Create an
AggregationDefinition to find the standard deviation of the non-null values ofvalue
(which defaults to field
).
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <IntegerType | FloatType > | the value to aggregate |
Returns
StandardAggregationDefinition
<FloatType
>
the
StdDev StandardAggregationDefinitionExample
// ...
aggregations: {
// find the std deviation of Qty's
StdDevQty: fields => StdDev(fields.Qty),
// ...
}
Sum
▸ Sum(value
):
StandardAggregationDefinition
<IntegerType
>
Create an
AggregationDefinition to find the sum of the non-null values ofvalue
(which defaults to field
).
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <IntegerType > | the value to aggregate |
Returns
StandardAggregationDefinition
<IntegerType
>
the
Sum StandardAggregationDefinitionExample
// ...
aggregations: {
// sum all Qty's to find the total
TotalQty: fields => Sum(fields.Qty),
// ...
}
Unique
▸ Unique<T
>(value
): T
extends
NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>>
Create an Aggregation
to find the unique non-null value of value
. If multiple non-null values are encountered, it returns null.
Type parameters
Name | Type |
---|---|
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
value | EastFunction <T > | the value to aggregate |
Returns
T
extends
NullType
? StandardAggregationDefinition
<T
> : StandardAggregationDefinition
<Nullable
<T
>>
the
Unique StandardAggregationDefinitionExample
// ...
aggregations: {
// count the number of unique non-null Category's
Categories: fields => Unique(fields.Category),
// ...
}