Skip to content

Commit 5e9d01b

Browse files
committed
Add first_value and last_value aggregations and allow winsorization.
1 parent 55f32b6 commit 5e9d01b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

eppo_metrics_sync/validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def aggregation_is_valid(aggregation):
112112
error_message = []
113113

114114
if aggregation['operation'] not in ['sum', 'count', 'count_distinct', 'distinct_entity', 'threshold', 'retention',
115-
'conversion']:
115+
'conversion', 'last_value', 'first_value']:
116116
error_message.append(
117117
'Invalid aggregation operation: ' + aggregation['operation']
118118
)
119119

120120
# can only winsorize sum or count metrics
121-
if aggregation['operation'] not in ['sum', 'count']:
121+
if aggregation['operation'] not in ['sum', 'count', 'last_value', 'first_value']:
122122
if [name for name in winsorization_parameters if name in aggregation]:
123123
error_message.append(
124124
'Cannot winsorize a metric with operation ' + aggregation['operation']

tests/test_validation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,11 @@ def test_count_distinct():
129129

130130
res = aggregation_is_valid(test_agg)
131131
assert res == None
132+
133+
def test_last_value():
134+
res = aggregation_is_valid({'operation': 'last_value'})
135+
assert res == None
136+
137+
def test_first_value():
138+
res = aggregation_is_valid({'operation': 'first_value'})
139+
assert res == None

0 commit comments

Comments
 (0)