You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Installation method: docker (also happens on Timescale Cloud)
Describe the bug
Using topn() on a large number of NULL rows causes an Option::unwrap() error.
On a smaller number of rows it works as expected.
To Reproduce
Steps to reproduce the behavior:
Start the image timescale/timescaledb-ha:pg15-all.
(This is how I reproduced it, but it probably happens on all recent versions)
Run the following SQL to setup the database:
CREATE TABLE public.example (time TIMESTAMPTZ NOT NULL, string_value TEXT NULL);
INSERT INTO public.example (time, string_value)
SELECT time, NULL AS string_value
FROM generate_series(now() - interval '5 day', now(), interval '1 second') AS g1(time);
Run the following query to trigger the bug: SELECT topn(mcv_agg(1, string_value)) FROM public.example;
See the error ERROR: called 'Option::unwrap()' on a 'None' value
Expected behavior
On smaller (NULL) datasets topn() results in:
topn
------
(0 rows)
I expect this behaviour not to change depending on dataset size.
Actual behavior
On larger (NULL) datasets topn() results in:
ERROR: called `Option::unwrap()` on a `None` value
Additional context
The bug can be reproduced on Timescale Cloud and locally in docker.
This bug was particularly pernicious because it only occurs on larger datasets.
So we didn't encounter it during testing.
Workaround
A Timescale Support agent quickly provided us with a workaround.
Replacing string_value with COALESCE(string_value,''::text)),
e.g. SELECT topn(mcv_agg(1, COALESCE(string_value,''::text))) FROM public.example;
Which changes the behaviour to return an empty string instead of no results.
But did solve our production issue.
The text was updated successfully, but these errors were encountered:
Relevant system information:
Describe the bug
Using
topn()
on a large number ofNULL
rows causes anOption::unwrap()
error.On a smaller number of rows it works as expected.
To Reproduce
Steps to reproduce the behavior:
timescale/timescaledb-ha:pg15-all
.(This is how I reproduced it, but it probably happens on all recent versions)
SELECT topn(mcv_agg(1, string_value)) FROM public.example;
ERROR: called 'Option::unwrap()' on a 'None' value
Expected behavior
On smaller (
NULL
) datasetstopn()
results in:I expect this behaviour not to change depending on dataset size.
Actual behavior
On larger (
NULL
) datasetstopn()
results in:Additional context
The bug can be reproduced on Timescale Cloud and locally in docker.
This bug was particularly pernicious because it only occurs on larger datasets.
So we didn't encounter it during testing.
Workaround
A Timescale Support agent quickly provided us with a workaround.
Replacing
string_value
withCOALESCE(string_value,''::text))
,e.g.
SELECT topn(mcv_agg(1, COALESCE(string_value,''::text))) FROM public.example;
Which changes the behaviour to return an empty string instead of no results.
But did solve our production issue.
The text was updated successfully, but these errors were encountered: