Skip to content

[SPARK-52407][SQL] Add support for Theta Sketch #51298

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

cboumalh
Copy link

@cboumalh cboumalh commented Jun 27, 2025

What changes were proposed in this pull request?

This PR's goal is to provide 7 new functions which utilize Theta Sketches.
The functions are:

theta_sketch_agg(sketch_col)
theta_union(sketch1, sketch2)
theta_union_agg(sketch_col)
theta_difference(sketch1, sketch2)
theta_intersection(sketch1, sketch2)
theta_intersection_agg(sketch_col)
theta_sketch_estimate(sketch)

Why are the changes needed?

Today, Spark supports HyperLogLog. HLL only supports the union set operation. Theta on the other hand allows us to find the difference and intersection between two sketches.

Does this PR introduce any user-facing change?

Yes, this PR introduces three new aggregate functions:

theta_sketch_agg
theta_intersection_agg
theta_union_agg

And four new scalar functions:

theta_sketch_estimate
theta_intersection
theta_difference
theta_union

How was this patch tested?

I've included some tests in ThetasketchesAggSuite test suite. I also tested it locally on my machine.

Was this patch authored or co-authored using generative AI tooling?

No

Jira

https://issues.apache.org/jira/browse/SPARK-52407

@github-actions github-actions bot added the SQL label Jun 27, 2025
@cboumalh cboumalh force-pushed the SPARK-52407_add_datasketches_thetasketch branch from b301ac8 to e9a2cbe Compare June 27, 2025 01:12
@cboumalh
Copy link
Author

cboumalh commented Jun 27, 2025

I know there is probably a lot missing in the PR before it's ready to merge. Please let me know!
@mkaravel @RyanBerti

@cboumalh cboumalh marked this pull request as draft June 27, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant