Skip to content
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

Add NULL support to rollup(hyperloglog) #649

Closed
jerryxwu opened this issue Dec 7, 2022 · 0 comments · Fixed by #742
Closed

Add NULL support to rollup(hyperloglog) #649

jerryxwu opened this issue Dec 7, 2022 · 0 comments · Fixed by #742
Assignees
Labels
feature-request And area of analysis that could be made easier

Comments

@jerryxwu
Copy link
Contributor

jerryxwu commented Dec 7, 2022

Is your feature request related to a problem? Please describe.
Add NULL support to rollup(hyperloglog) to improve user experience.

Describe the solution you'd like
rollup(hyperloglog) should simply ignore NULL hyperloglog objects instead of returning an error. For Toolkit 1.12.0, the returned error is:

ERROR: other_ is null
CONTEXT: extension/src/hyperloglog.rs:277:5

Consider this query:

SELECT distinct_count(rollup(logs))
FROM (
	(SELECT hyperloglog(16, v::text) logs FROM generate_series(1, 5) v)
	UNION ALL
	(SELECT hyperloglog(16, v::text) FROM generate_series(6, 10) v WHERE v <=5)
) hll;

It should return the same value as this query as the second hyperloglog object will be NULL:

SELECT distinct_count(rollup(logs))
FROM (
	(SELECT hyperloglog(16, v::text) logs FROM generate_series(1, 5) v)
) hll;

Describe alternatives you've considered
An alternative is to do nothing and ask the user to always include FILTER (WHERE hll IS NOT NULL) clause if hll can be null. For the example above, the query would look like this,

SELECT distinct_count(rollup(logs) FILTER (WHERE logs IS NOT NULL))
FROM (
	(SELECT hyperloglog(16, v::text) logs FROM generate_series(1, 5) v)
	UNION ALL
	(SELECT hyperloglog(16, v::text) FROM generate_series(6, 10) v WHERE v <=5)
) hll;

The alternative works, it's just more boilerplate SQL code to write.

@jerryxwu jerryxwu added the feature-request And area of analysis that could be made easier label Dec 7, 2022
@WireBaron WireBaron self-assigned this Mar 16, 2023
bors bot added a commit that referenced this issue Mar 29, 2023
742: Handle NULL values in hyperloglog rollup r=WireBaron a=WireBaron

Fixes #649

Co-authored-by: Brian Rowe <brian@timescale.com>
@bors bors bot closed this as completed in 74495aa Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request And area of analysis that could be made easier
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants