Ejemplo n.º 1
0
 def test_filtered_aggregator(self):
     filter_ = filters.Filter(dimension="dim", value="val")
     aggs = [
         aggregators.count("metric1"),
         aggregators.longsum("metric2"),
         aggregators.doublesum("metric3"),
         aggregators.doublemin("metric4"),
         aggregators.doublemax("metric5"),
         aggregators.hyperunique("metric6"),
         aggregators.cardinality("dim1"),
         aggregators.cardinality(["dim1", "dim2"], by_row=True),
         aggregators.thetasketch("dim1"),
         aggregators.thetasketch("metric7"),
         aggregators.thetasketch("metric8",
                                 isinputthetasketch=True,
                                 size=8192),
     ]
     for agg in aggs:
         expected = {
             "type": "filtered",
             "filter": {
                 "type": "selector",
                 "dimension": "dim",
                 "value": "val"
             },
             "aggregator": agg,
         }
         actual = aggregators.filtered(filter_, agg)
         assert actual == expected
Ejemplo n.º 2
0
 def test_filtered_aggregator(self):
     filter_ = filters.Filter(dimension='dim', value='val')
     aggs = [aggregators.count('metric1'),
             aggregators.longsum('metric2'),
             aggregators.doublesum('metric3'),
             aggregators.doublemin('metric4'),
             aggregators.doublemax('metric5'),
             aggregators.hyperunique('metric6'),
             aggregators.cardinality('dim1'),
             aggregators.cardinality(['dim1', 'dim2'], by_row=True),
             aggregators.thetasketch('dim1'),
             aggregators.thetasketch('metric7'),
             aggregators.thetasketch('metric8', isinputthetasketch=True, size=8192)
            ]
     for agg in aggs:
         expected = {
             'type': 'filtered',
             'filter': {
                 'type': 'selector',
                 'dimension': 'dim',
                 'value': 'val'
             },
             'aggregator': agg
         }
         actual = aggregators.filtered(filter_, agg)
         assert actual == expected
Ejemplo n.º 3
0
    def test_build_aggregators(self):
        agg_input = {
            'agg1': aggregators.count('metric1'),
            'agg2': aggregators.longsum('metric2'),
            '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)
        }
        built_agg = aggregators.build_aggregators(agg_input)
        expected = [
            {'name': 'agg1', 'type': 'count', 'fieldName': 'metric1'},
            {'name': 'agg2', 'type': 'longSum', 'fieldName': 'metric2'},
            {'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': 'agg7', 'type': 'cardinality', 'fieldNames': ['dim1'], 'byRow': False},
            {'name': 'agg8', 'type': 'cardinality', 'fieldNames': ['dim1', 'dim2'], 'byRow': True},
            {'name': 'agg9', 'type': 'thetaSketch', 'fieldName': 'dim1', 'isInputThetaSketch': False, 'size': 16384},
            {'name': 'agg10', 'type': 'thetaSketch', 'fieldName': 'metric7', 'isInputThetaSketch': False, 'size': 16384},
            {'name': 'agg11', 'type': 'thetaSketch', 'fieldName': 'metric8', 'isInputThetaSketch': True, 'size': 8192}

        ]
        assert (sorted(built_agg, key=itemgetter('name')) ==
                sorted(expected, key=itemgetter('name')))
Ejemplo n.º 4
0
    def test_build_filtered_aggregator(self):
        filter_ = filters.Filter(dimension="dim", value="val")
        agg_input = {
            "agg1": aggregators.filtered(filter_, aggregators.count("metric1")),
            "agg2": aggregators.filtered(filter_, aggregators.longsum("metric2")),
            "agg3": aggregators.filtered(filter_, aggregators.doublesum("metric3")),
            "agg4": aggregators.filtered(filter_, aggregators.min("metric4")),
            "agg5": aggregators.filtered(filter_, aggregators.max("metric5")),
            "agg6": aggregators.filtered(filter_, aggregators.hyperunique("metric6")),
            "agg7": aggregators.filtered(filter_, aggregators.cardinality("dim1")),
            "agg8": aggregators.filtered(filter_, aggregators.cardinality(["dim1", "dim2"], by_row=True)),
        }
        base = {"type": "filtered", "filter": {"type": "selector", "dimension": "dim", "value": "val"}}

        aggs = [
            {"name": "agg1", "type": "count", "fieldName": "metric1"},
            {"name": "agg2", "type": "longSum", "fieldName": "metric2"},
            {"name": "agg3", "type": "doubleSum", "fieldName": "metric3"},
            {"name": "agg4", "type": "min", "fieldName": "metric4"},
            {"name": "agg5", "type": "max", "fieldName": "metric5"},
            {"name": "agg6", "type": "hyperUnique", "fieldName": "metric6"},
            {"name": "agg7", "type": "cardinality", "fieldNames": ["dim1"], "byRow": False},
            {"name": "agg8", "type": "cardinality", "fieldNames": ["dim1", "dim2"], "byRow": True},
        ]
        expected = []
        for agg in aggs:
            exp = deepcopy(base)
            exp.update({"aggregator": agg})
            expected.append(exp)

        built_agg = aggregators.build_aggregators(agg_input)
        expected = sorted(built_agg, key=lambda k: itemgetter("name")(itemgetter("aggregator")(k)))
        actual = sorted(expected, key=lambda k: itemgetter("name")(itemgetter("aggregator")(k)))
        assert expected == actual
Ejemplo n.º 5
0
 def test_build_aggregators(self):
     agg_input = {
         'agg1': aggregators.count('metric1'),
         'agg2': aggregators.longsum('metric2'),
         'agg3': aggregators.doublesum('metric3'),
         'agg4': aggregators.min('metric4'),
         'agg5': aggregators.max('metric5'),
         'agg6': aggregators.hyperunique('metric6'),
         'agg7': aggregators.cardinality('dim1'),
         'agg8': aggregators.cardinality(['dim1', 'dim2'], by_row=True)
     }
     built_agg = aggregators.build_aggregators(agg_input)
     expected = [
         {
             'name': 'agg1',
             'type': 'count',
             'fieldName': 'metric1'
         },
         {
             'name': 'agg2',
             'type': 'longSum',
             'fieldName': 'metric2'
         },
         {
             'name': 'agg3',
             'type': 'doubleSum',
             'fieldName': 'metric3'
         },
         {
             'name': 'agg4',
             'type': 'min',
             'fieldName': 'metric4'
         },
         {
             'name': 'agg5',
             'type': 'max',
             'fieldName': 'metric5'
         },
         {
             'name': 'agg6',
             'type': 'hyperUnique',
             'fieldName': 'metric6'
         },
         {
             'name': 'agg7',
             'type': 'cardinality',
             'fieldNames': ['dim1'],
             'byRow': False
         },
         {
             'name': 'agg8',
             'type': 'cardinality',
             'fieldNames': ['dim1', 'dim2'],
             'byRow': True
         },
     ]
     assert (sorted(built_agg, key=itemgetter('name')) == sorted(
         expected, key=itemgetter('name')))
Ejemplo n.º 6
0
    def test_build_filtered_aggregator(self):
        filter_ = filters.Filter(dimension='dim', value='val')
        agg_input = {
            'agg1': aggregators.filtered(filter_,
                                         aggregators.count('metric1')),
            'agg2': aggregators.filtered(filter_,
                                         aggregators.longsum('metric2')),
            'agg3': aggregators.filtered(filter_,
                                         aggregators.doublesum('metric3')),
            'agg4': aggregators.filtered(filter_,
                                         aggregators.min('metric4')),
            'agg5': aggregators.filtered(filter_,
                                         aggregators.max('metric5')),
            'agg6': aggregators.filtered(filter_,
                                         aggregators.hyperunique('metric6')),
            'agg7': aggregators.filtered(filter_,
                                         aggregators.cardinality('dim1')),
            'agg8': aggregators.filtered(filter_,
                                         aggregators.cardinality(['dim1', 'dim2'], by_row=True)),
        }
        base = {
            'type': 'filtered',
            'filter': {
                'type': 'selector',
                'dimension': 'dim',
                'value': 'val'
            }
        }

        aggs = [
            {'name': 'agg1', 'type': 'count', 'fieldName': 'metric1'},
            {'name': 'agg2', 'type': 'longSum', 'fieldName': 'metric2'},
            {'name': 'agg3', 'type': 'doubleSum', 'fieldName': 'metric3'},
            {'name': 'agg4', 'type': 'min', 'fieldName': 'metric4'},
            {'name': 'agg5', 'type': 'max', 'fieldName': 'metric5'},
            {'name': 'agg6', 'type': 'hyperUnique', 'fieldName': 'metric6'},
            {'name': 'agg7', 'type': 'cardinality', 'fieldNames': ['dim1'], 'byRow': False},
            {'name': 'agg8', 'type': 'cardinality', 'fieldNames': ['dim1', 'dim2'], 'byRow': True},
        ]
        expected = []
        for agg in aggs:
            exp = deepcopy(base)
            exp.update({'aggregator': agg})
            expected.append(exp)

        built_agg = aggregators.build_aggregators(agg_input)
        expected = sorted(built_agg, key=lambda k: itemgetter('name')(
            itemgetter('aggregator')(k)))
        actual = sorted(expected, key=lambda k: itemgetter('name')(
            itemgetter('aggregator')(k)))
        assert expected == actual
Ejemplo n.º 7
0
    def get(self, request):
        query = create_druid_client()
        last_week_start_date = (datetime.now() -
                                timedelta(days=7)).strftime("%Y-%m-%d")
        today_date = datetime.now().strftime("%Y-%m-%d")

        query_result = query.groupby(
            datasource='celtra3',
            granularity='week',
            dimensions=['adId'],
            intervals=["{0}/{1}".format(last_week_start_date, today_date)],
            aggregations={
                'user': hyperunique('user'),
                'impressions': doublesum('impressions')
            },
        )

        return Response(query_result.result)
Ejemplo n.º 8
0
 def test_filtered_aggregator(self):
     filter_ = filters.Filter(dimension="dim", value="val")
     aggs = [
         aggregators.count("metric1"),
         aggregators.longsum("metric2"),
         aggregators.doublesum("metric3"),
         aggregators.min("metric4"),
         aggregators.max("metric5"),
         aggregators.hyperunique("metric6"),
         aggregators.cardinality("dim1"),
         aggregators.cardinality(["dim1", "dim2"], by_row=True),
     ]
     for agg in aggs:
         expected = {
             "type": "filtered",
             "filter": {"type": "selector", "dimension": "dim", "value": "val"},
             "aggregator": agg,
         }
         actual = aggregators.filtered(filter_, agg)
         assert actual == expected
Ejemplo n.º 9
0
 def test_build_aggregators(self):
     agg_input = {
         'agg1': aggregators.count('metric1'),
         'agg2': aggregators.longsum('metric2'),
         'agg3': aggregators.doublesum('metric3'),
         'agg4': aggregators.min('metric4'),
         'agg5': aggregators.max('metric5'),
         'agg6': aggregators.hyperunique('metric6')
     }
     built_agg = aggregators.build_aggregators(agg_input)
     expected = [
         {'name': 'agg1', 'type': 'count', 'fieldName': 'metric1'},
         {'name': 'agg2', 'type': 'longSum', 'fieldName': 'metric2'},
         {'name': 'agg3', 'type': 'doubleSum', 'fieldName': 'metric3'},
         {'name': 'agg4', 'type': 'min', 'fieldName': 'metric4'},
         {'name': 'agg5', 'type': 'max', 'fieldName': 'metric5'},
         {'name': 'agg6', 'type': 'hyperUnique', 'fieldName': 'metric6'},
     ]
     assert (sorted(built_agg, key=itemgetter('name')) ==
             sorted(expected, key=itemgetter('name')))
Ejemplo n.º 10
0
 def test_filtered_aggregator(self):
     filter_ = filters.Filter(dimension='dim', value='val')
     aggs = [aggregators.count('metric1'),
             aggregators.longsum('metric2'),
             aggregators.doublesum('metric3'),
             aggregators.min('metric4'),
             aggregators.max('metric5'),
             aggregators.hyperunique('metric6')]
     for agg in aggs:
         expected = {
             'type': 'filtered',
             'filter': {
                 'type': 'selector',
                 'dimension': 'dim',
                 'value': 'val'
             },
             'aggregator': agg
         }
         actual = aggregators.filtered(filter_, agg)
         assert actual == expected
Ejemplo n.º 11
0
 def test_build_aggregators(self):
     agg_input = {
         "agg1": aggregators.count("metric1"),
         "agg2": aggregators.longsum("metric2"),
         "agg3": aggregators.doublesum("metric3"),
         "agg4": aggregators.min("metric4"),
         "agg5": aggregators.max("metric5"),
         "agg6": aggregators.hyperunique("metric6"),
         "agg7": aggregators.cardinality("dim1"),
         "agg8": aggregators.cardinality(["dim1", "dim2"], by_row=True),
     }
     built_agg = aggregators.build_aggregators(agg_input)
     expected = [
         {"name": "agg1", "type": "count", "fieldName": "metric1"},
         {"name": "agg2", "type": "longSum", "fieldName": "metric2"},
         {"name": "agg3", "type": "doubleSum", "fieldName": "metric3"},
         {"name": "agg4", "type": "min", "fieldName": "metric4"},
         {"name": "agg5", "type": "max", "fieldName": "metric5"},
         {"name": "agg6", "type": "hyperUnique", "fieldName": "metric6"},
         {"name": "agg7", "type": "cardinality", "fieldNames": ["dim1"], "byRow": False},
         {"name": "agg8", "type": "cardinality", "fieldNames": ["dim1", "dim2"], "byRow": True},
     ]
     assert sorted(built_agg, key=itemgetter("name")) == sorted(expected, key=itemgetter("name"))
Ejemplo n.º 12
0
 def test_build_aggregators(self):
     agg_input = {
         'agg1': aggregators.count('metric1'),
         'agg2': aggregators.longsum('metric2'),
         'agg3': aggregators.doublesum('metric3'),
         'agg4': aggregators.min('metric4'),
         'agg5': aggregators.max('metric5'),
         'agg6': aggregators.hyperunique('metric6'),
         'agg7': aggregators.cardinality('dim1'),
         'agg8': aggregators.cardinality(['dim1', 'dim2'], by_row=True)
     }
     built_agg = aggregators.build_aggregators(agg_input)
     expected = [
         {'name': 'agg1', 'type': 'count', 'fieldName': 'metric1'},
         {'name': 'agg2', 'type': 'longSum', 'fieldName': 'metric2'},
         {'name': 'agg3', 'type': 'doubleSum', 'fieldName': 'metric3'},
         {'name': 'agg4', 'type': 'min', 'fieldName': 'metric4'},
         {'name': 'agg5', 'type': 'max', 'fieldName': 'metric5'},
         {'name': 'agg6', 'type': 'hyperUnique', 'fieldName': 'metric6'},
         {'name': 'agg7', 'type': 'cardinality', 'fieldNames': ['dim1'], 'byRow': False},
         {'name': 'agg8', 'type': 'cardinality', 'fieldNames': ['dim1', 'dim2'], 'byRow': True},
     ]
     assert (sorted(built_agg, key=itemgetter('name')) ==
             sorted(expected, key=itemgetter('name')))
Ejemplo n.º 13
0
    def __init__(self, field, hyper_unique_field):
        aggregations = {field: hyperunique(hyper_unique_field)}

        super(HyperUniqueCountCalculation,
              self).__init__(aggregations=aggregations)
Ejemplo n.º 14
0
 def test_build_aggregators(self):
     agg_input = {
         "agg1":
         aggregators.count("metric1"),
         "agg2":
         aggregators.longsum("metric2"),
         "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),
     }
     built_agg = aggregators.build_aggregators(agg_input)
     expected = [
         {
             "name": "agg1",
             "type": "count",
             "fieldName": "metric1"
         },
         {
             "name": "agg2",
             "type": "longSum",
             "fieldName": "metric2"
         },
         {
             "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": "agg7",
             "type": "cardinality",
             "fieldNames": ["dim1"],
             "byRow": False,
         },
         {
             "name": "agg8",
             "type": "cardinality",
             "fieldNames": ["dim1", "dim2"],
             "byRow": True,
         },
         {
             "name": "agg9",
             "type": "thetaSketch",
             "fieldName": "dim1",
             "isInputThetaSketch": False,
             "size": 16384,
         },
         {
             "name": "agg10",
             "type": "thetaSketch",
             "fieldName": "metric7",
             "isInputThetaSketch": False,
             "size": 16384,
         },
         {
             "name": "agg11",
             "type": "thetaSketch",
             "fieldName": "metric8",
             "isInputThetaSketch": True,
             "size": 8192,
         },
     ]
     assert sorted(built_agg,
                   key=itemgetter("name")) == sorted(expected,
                                                     key=itemgetter("name"))
Ejemplo n.º 15
0
    def test_build_filtered_aggregator(self):
        filter_ = filters.Filter(dimension="dim", value="val")
        agg_input = {
            "agg1":
            aggregators.filtered(filter_, aggregators.count("metric1")),
            "agg2":
            aggregators.filtered(filter_, aggregators.longsum("metric2")),
            "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(
                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(
                filter_,
                aggregators.thetasketch("metric8",
                                        isinputthetasketch=True,
                                        size=8192),
            ),
        }
        base = {
            "type": "filtered",
            "filter": {
                "type": "selector",
                "dimension": "dim",
                "value": "val"
            },
        }

        aggs = [
            {
                "name": "agg1",
                "type": "count",
                "fieldName": "metric1"
            },
            {
                "name": "agg2",
                "type": "longSum",
                "fieldName": "metric2"
            },
            {
                "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": "agg7",
                "type": "cardinality",
                "fieldNames": ["dim1"],
                "byRow": False,
            },
            {
                "name": "agg8",
                "type": "cardinality",
                "fieldNames": ["dim1", "dim2"],
                "byRow": True,
            },
            {
                "name": "agg9",
                "type": "thetaSketch",
                "fieldName": "dim1",
                "isInputThetaSketch": False,
                "size": 16384,
            },
            {
                "name": "agg10",
                "type": "thetaSketch",
                "fieldName": "metric7",
                "isInputThetaSketch": False,
                "size": 16384,
            },
            {
                "name": "agg11",
                "type": "thetaSketch",
                "fieldName": "metric8",
                "isInputThetaSketch": True,
                "size": 8192,
            },
        ]
        expected = []
        for agg in aggs:
            exp = deepcopy(base)
            exp.update({"aggregator": agg})
            expected.append(exp)

        built_agg = aggregators.build_aggregators(agg_input)
        expected = sorted(built_agg,
                          key=lambda k: itemgetter("name")
                          (itemgetter("aggregator")(k)))
        actual = sorted(expected,
                        key=lambda k: itemgetter("name")
                        (itemgetter("aggregator")(k)))
        assert expected == actual
Ejemplo n.º 16
0
    def test_build_filtered_aggregator(self):
        filter_ = filters.Filter(dimension='dim', value='val')
        agg_input = {
            'agg1': aggregators.filtered(filter_,
                                         aggregators.count('metric1')),
            'agg2': aggregators.filtered(filter_,
                                         aggregators.longsum('metric2')),
            '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(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(filter_,
                                         aggregators.thetasketch('metric8', isinputthetasketch = True, size=8192)),
        }
        base = {
            'type': 'filtered',
            'filter': {
                'type': 'selector',
                'dimension': 'dim',
                'value': 'val'
            }
        }

        aggs = [
            {'name': 'agg1', 'type': 'count', 'fieldName': 'metric1'},
            {'name': 'agg2', 'type': 'longSum', 'fieldName': 'metric2'},
            {'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': 'agg7', 'type': 'cardinality', 'fieldNames': ['dim1'], 'byRow': False},
            {'name': 'agg8', 'type': 'cardinality', 'fieldNames': ['dim1', 'dim2'], 'byRow': True},
            {'name': 'agg9', 'type': 'thetaSketch', 'fieldName': 'dim1', 'isInputThetaSketch': False, 'size': 16384},
            {'name': 'agg10', 'type': 'thetaSketch', 'fieldName': 'metric7', 'isInputThetaSketch': False, 'size': 16384},
            {'name': 'agg11', 'type': 'thetaSketch', 'fieldName': 'metric8', 'isInputThetaSketch': True, 'size': 8192}

        ]
        expected = []
        for agg in aggs:
            exp = deepcopy(base)
            exp.update({'aggregator': agg})
            expected.append(exp)

        built_agg = aggregators.build_aggregators(agg_input)
        expected = sorted(built_agg, key=lambda k: itemgetter('name')(
            itemgetter('aggregator')(k)))
        actual = sorted(expected, key=lambda k: itemgetter('name')(
            itemgetter('aggregator')(k)))
        assert expected == actual