Skip to content

Replace deprecated stateful UDAFs with typed aggregators - #760

Merged
SamPom100 merged 1 commit into
masterfrom
fix/issue-583-typed-aggregators
Jul 17, 2026
Merged

Replace deprecated stateful UDAFs with typed aggregators#760
SamPom100 merged 1 commit into
masterfrom
fix/issue-583-typed-aggregators

Conversation

@SamPom100

@SamPom100 SamPom100 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

Fixes #583

Description of changes:

This replaces the deprecated UserDefinedAggregateFunction implementations for the DataType and KLLSketch analyzers with Spark's typed Aggregator API.

The main improvement is in KLL processing. The old implementation serialized and deserialized the sketch for every input row. The new aggregator keeps the sketch in memory while processing a partition and only serializes it when Spark needs to encode the aggregation buffer. DataType now uses a typed buffer containing the same five counters as before.

The existing output formats and behavior are unchanged. I added tests that compare the old and new implementations byte for byte, including null and empty inputs, shuffled partitions, KLL compaction, special floating-point values, separate physical plans, and object-hash fallback.

Validation performed:

  • StatefulAggregatorsTest: 7 tests passed
  • AnalyzerTests: 98 tests passed
  • KLLProfileTest: 3 tests passed
  • Scala 2.12.10 compilation, Scalastyle, and RAT checks passed

In a small local Spark 3.5.7 benchmark, KLL was about 11% faster. DataType was about 12% slower, so this change should not be considered a performance improvement for that analyzer; it does remove its use of the deprecated API.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.


Generated by AI (model: us.anthropic.claude-opus-4-8, prompt: 4d2f5d73) — may not be fully accurate. Reply if this doesn't help.
Reviewed by Shadow · github.com/sudsali/shadow

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found and CI is passing. Auto-approved.


Generated by AI — human merge required.

@SamPom100
SamPom100 merged commit 8de27d2 into master Jul 17, 2026
6 checks passed
@sudsali
sudsali deleted the fix/issue-583-typed-aggregators branch July 17, 2026 20:32
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.

[FEATURE] Improve performance of KLLSketch and DataType Analyzer

2 participants