MCPcopy Create free account
hub / github.com/apache/arrow / test_hash_agg_random

Function test_hash_agg_random

python/pyarrow/tests/test_udf.py:864–879  ·  view source on GitHub ↗

Test hash aggregate udf with randomly sampled data

(sum_agg_func_fixture)

Source from the content-addressed store, hash-verified

862
863@pytest.mark.numpy
864def test_hash_agg_random(sum_agg_func_fixture):
865 """Test hash aggregate udf with randomly sampled data"""
866
867 value_num = 1000000
868 group_num = 1000
869
870 arr1 = pa.array(np.repeat(1, value_num), pa.float64())
871 arr2 = pa.array(np.random.choice(group_num, value_num), pa.int32())
872
873 table = pa.table([arr2, arr1], names=['id', 'value'])
874
875 result = table.group_by("id").aggregate([("value", "sum_udf")])
876 expected = table.group_by("id").aggregate(
877 [("value", "sum")]).rename_columns(['id', 'value_sum_udf'])
878
879 assert result.sort_by('id') == expected.sort_by('id')
880
881
882@pytest.mark.pandas

Callers

nothing calls this directly

Calls 2

aggregateMethod · 0.80
arrayMethod · 0.45

Tested by

no test coverage detected