Skip to content

[python] Introduce hll_sketch aggregator function - #9274

Open
zhuxiangyi wants to merge 1 commit into
apache:masterfrom
zhuxiangyi:feature/pypaimon-hll-sketch-agg-impl
Open

[python] Introduce hll_sketch aggregator function#9274
zhuxiangyi wants to merge 1 commit into
apache:masterfrom
zhuxiangyi:feature/pypaimon-hll-sketch-agg-impl

Conversation

@zhuxiangyi

Copy link
Copy Markdown
Contributor

Purpose

This PR introduces the Python FieldHllSketchAgg implementation and aligns the
Python HyperLogLog aggregation behavior with the Java implementation.

The changes include:

  • Add hll_sketch field aggregation support, mirroring Java's
    HllSketchUtil.union (the union is seeded from the input sketch, and the
    result is emitted as a compact HLL_4 sketch).
  • Add VARBINARY type validation, matching FieldHllSketchAggFactory.
  • Keep datasketches an optional dependency: the import is lazy and raises a
    clear pypaimon[hll-sketch] hint, following the theta_sketch precedent.
  • Register hll_sketch in merge_engine_support._AGGREGATION_SUPPORTED_AGG_FUNCS
    and narrow the "unsupported aggregators" message to rbm64.
  • Pin cross-language compatibility with fixtures produced by Java's
    HllSketchUtil (datasketches-java 4.2.0, lgK=12), verified in both directions.
  • Extend the RegistrationTest.EXPECTED list, which was still pinned to the 10
    aggregators from the initial scope in [python] Implement aggregation merge engine in pypaimon #7952, to all 20, and add a test
    asserting the registry and the merge-engine guard list stay in sync.

rbm64 remains deferred: Java serializes it with Roaring64Bitmap's private ART
format, which has no portable counterpart in pyroaring, so the bytes are not
interchangeable in either direction. The module docstring now records that reason.

Tests

  • python -m pytest pypaimon/tests/test_field_aggregators.py -q
  • python -m pytest pypaimon/tests/test_aggregation_e2e.py -q
  • python -m pytest pypaimon/tests/test_aggregation_merge_function.py -q
  • python -m pytest pypaimon/tests/test_field_aggregator_registry.py -q
  • python -m pytest pypaimon/tests/test_merge_engine_dispatch.py -q
  • python -m pytest pypaimon/tests/test_optional_datasketches_dependency.py -q
  • flake8 --config=dev/cfg.ini

Add the Python FieldHllSketchAgg implementation and align the HLL
aggregation behaviour with Java's FieldHllSketchAgg / HllSketchUtil:
the union is seeded from the input sketch and the result is emitted as
a compact HLL_4 sketch, so the serialized bytes stay interchangeable
with HllSketch.toCompactByteArray().

datasketches stays an optional dependency: the import is lazy and
raises a clear pypaimon[hll-sketch] hint, following the theta_sketch
precedent.

Register the identifier in merge_engine_support so the guard stops
rejecting it, and narrow the "unsupported aggregators" message to
rbm64. rbm64 remains deferred because Java serializes it with
Roaring64Bitmap's private ART format, which has no portable
counterpart in pyroaring; the module docstring now records that.

Also extend RegistrationTest.EXPECTED, which was still pinned to the
10 aggregators from the initial scope, to all 20, and assert the
registry and the merge-engine guard list stay in sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant