Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pydruid/utils/aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ def doublemax(raw_metric):
return {"type": "doubleMax", "fieldName": raw_metric}


def doublemean(raw_metric):
return {"type": "doubleMean", "fieldName": raw_metric}


def count(raw_metric):
return {"type": "count", "fieldName": raw_metric}

Expand Down
66 changes: 36 additions & 30 deletions tests/utils/test_aggregators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_aggregators(self):
("doublesum", "doubleSum"),
("doublemin", "doubleMin"),
("doublemax", "doubleMax"),
("doublemean", "doubleMean"),
("count", "count"),
("hyperunique", "hyperUnique"),
("stringfirst", "stringFirst"),
Expand All @@ -34,12 +35,13 @@ def test_filtered_aggregator(self):
aggregators.doublesum("metric3"),
aggregators.doublemin("metric4"),
aggregators.doublemax("metric5"),
aggregators.hyperunique("metric6"),
aggregators.doublemean("metric6"),
aggregators.hyperunique("metric7"),
aggregators.cardinality("dim1"),
aggregators.cardinality(["dim1", "dim2"], by_row=True),
aggregators.thetasketch("dim1"),
aggregators.thetasketch("metric7"),
aggregators.thetasketch("metric8", isinputthetasketch=True, size=8192),
aggregators.thetasketch("metric8"),
aggregators.thetasketch("metric9", isinputthetasketch=True, size=8192),
]
for agg in aggs:
expected = {
Expand Down Expand Up @@ -82,13 +84,14 @@ def test_build_aggregators(self):
"agg3": aggregators.doublesum("metric3"),
"agg4": aggregators.doublemin("metric4"),
"agg5": aggregators.doublemax("metric5"),
"agg6": aggregators.hyperunique("metric6"),
"agg7": aggregators.cardinality("dim1"),
"agg8": aggregators.cardinality(["dim1", "dim2"], by_row=True),
"agg9": aggregators.thetasketch("dim1"),
"agg10": aggregators.thetasketch("metric7"),
"agg11": aggregators.thetasketch(
"metric8", isinputthetasketch=True, size=8192
"agg6": aggregators.doublemean("metric6"),
"agg7": aggregators.hyperunique("metric7"),
"agg8": aggregators.cardinality("dim1"),
"agg9": aggregators.cardinality(["dim1", "dim2"], by_row=True),
"agg10": aggregators.thetasketch("dim1"),
"agg11": aggregators.thetasketch("metric8"),
"agg12": aggregators.thetasketch(
"metric9", isinputthetasketch=True, size=8192
),
}
built_agg = aggregators.build_aggregators(agg_input)
Expand All @@ -98,37 +101,38 @@ def test_build_aggregators(self):
{"name": "agg3", "type": "doubleSum", "fieldName": "metric3"},
{"name": "agg4", "type": "doubleMin", "fieldName": "metric4"},
{"name": "agg5", "type": "doubleMax", "fieldName": "metric5"},
{"name": "agg6", "type": "hyperUnique", "fieldName": "metric6"},
{"name": "agg6", "type": "doubleMean", "fieldName": "metric6"},
{"name": "agg7", "type": "hyperUnique", "fieldName": "metric7"},
{
"name": "agg7",
"name": "agg8",
"type": "cardinality",
"fieldNames": ["dim1"],
"byRow": False,
},
{
"name": "agg8",
"name": "agg9",
"type": "cardinality",
"fieldNames": ["dim1", "dim2"],
"byRow": True,
},
{
"name": "agg9",
"name": "agg10",
"type": "thetaSketch",
"fieldName": "dim1",
"isInputThetaSketch": False,
"size": 16384,
},
{
"name": "agg10",
"name": "agg11",
"type": "thetaSketch",
"fieldName": "metric7",
"fieldName": "metric8",
"isInputThetaSketch": False,
"size": 16384,
},
{
"name": "agg11",
"name": "agg12",
"type": "thetaSketch",
"fieldName": "metric8",
"fieldName": "metric9",
"isInputThetaSketch": True,
"size": 8192,
},
Expand All @@ -145,14 +149,15 @@ def test_build_filtered_aggregator(self):
"agg3": aggregators.filtered(filter_, aggregators.doublesum("metric3")),
"agg4": aggregators.filtered(filter_, aggregators.doublemin("metric4")),
"agg5": aggregators.filtered(filter_, aggregators.doublemax("metric5")),
"agg6": aggregators.filtered(filter_, aggregators.hyperunique("metric6")),
"agg7": aggregators.filtered(filter_, aggregators.cardinality("dim1")),
"agg8": aggregators.filtered(
"agg5": aggregators.filtered(filter_, aggregators.doublemean("metric6")),
"agg7": aggregators.filtered(filter_, aggregators.hyperunique("metric7")),
"agg8": aggregators.filtered(filter_, aggregators.cardinality("dim1")),
"agg9": aggregators.filtered(
filter_, aggregators.cardinality(["dim1", "dim2"], by_row=True)
),
"agg9": aggregators.filtered(filter_, aggregators.thetasketch("dim1")),
"agg10": aggregators.filtered(filter_, aggregators.thetasketch("metric7")),
"agg11": aggregators.filtered(
"agg10": aggregators.filtered(filter_, aggregators.thetasketch("dim1")),
"agg11": aggregators.filtered(filter_, aggregators.thetasketch("metric7")),
"agg12": aggregators.filtered(
filter_,
aggregators.thetasketch("metric8", isinputthetasketch=True, size=8192),
),
Expand All @@ -168,35 +173,36 @@ def test_build_filtered_aggregator(self):
{"name": "agg3", "type": "doubleSum", "fieldName": "metric3"},
{"name": "agg4", "type": "doubleMin", "fieldName": "metric4"},
{"name": "agg5", "type": "doubleMax", "fieldName": "metric5"},
{"name": "agg6", "type": "hyperUnique", "fieldName": "metric6"},
{"name": "agg6", "type": "doubleMean", "fieldName": "metric6"},
{"name": "agg7", "type": "hyperUnique", "fieldName": "metric7"},
{
"name": "agg7",
"name": "agg8",
"type": "cardinality",
"fieldNames": ["dim1"],
"byRow": False,
},
{
"name": "agg8",
"name": "agg9",
"type": "cardinality",
"fieldNames": ["dim1", "dim2"],
"byRow": True,
},
{
"name": "agg9",
"name": "agg10",
"type": "thetaSketch",
"fieldName": "dim1",
"isInputThetaSketch": False,
"size": 16384,
},
{
"name": "agg10",
"name": "agg11",
"type": "thetaSketch",
"fieldName": "metric7",
"isInputThetaSketch": False,
"size": 16384,
},
{
"name": "agg11",
"name": "agg12",
"type": "thetaSketch",
"fieldName": "metric8",
"isInputThetaSketch": True,
Expand Down