timescaledb-toolkit
timescaledb-toolkit copied to clipboard
`Option::unwrap()` error in t-digest `rollup()`
Relevant system information:
- OS: Ubuntu 22.04.1 LTS
- PostgreSQL version: PostgreSQL 14.6 (Ubuntu 14.6-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, 64-bit
- TimescaleDB Toolkit version: 1.13.0
- Installation method:
sudo apt install timescaledb-2-postgresql-14
Describe the bug
metrics=> select
time_bucket('1s', time),
rollup(time_100)
from demo
group by 1
order by 1;
ERROR: called `Option::unwrap()` on a `None` value
CONTEXT: parallel worker
To Reproduce I don't know how. I tried:
create table f(a tdigest);
insert into f(a) values ('(version:1,buckets:1,max_buckets:1,count:1,sum:1,min:1,max:1,centroids:[(mean:1,weight:1)])'), (null);
select rollup(a) from f; -- it worked
delete from f;
insert into f(a) values (null), ('(version:1,buckets:1,max_buckets:1,count:1,sum:1,min:1,max:1,centroids:[(mean:1,weight:1)])');
select rollup(a) from f; -- it worked
delete from f;
insert into f(a) values (null), ('(version:1,buckets:1,max_buckets:1,count:1,sum:1,min:1,max:1,centroids:[(mean:1,weight:1)])'), (null);
select rollup(a) from f; -- it worked
delete from f;
Here's my table:
metrics=> \d demo
Table "public.demo"
Column | Type | Collation | Nullable | Default
-------------+--------------------------+-----------+----------+---------
time | timestamp with time zone | | not null |
application | text | | |
time_100 | tdigest | | |
Indexes:
"demo_time_idx" btree ("time" DESC)
Triggers:
ts_insert_blocker BEFORE INSERT ON demo FOR EACH ROW EXECUTE FUNCTION _timescaledb_internal.insert_blocker()
Number of child tables: 3 (Use \d+ to list them.)
The column is sparse:
metrics=> select count(*) filter (where time_100 is not null) present, count(*) filter (where time_100 is null) absent from demo;
present | absent
---------+--------
18760 | 9712
Expected behavior
rollup()
function should work.
Actual behavior
rollup()
function attempted to call unwrap()
on a Rust Option
, which results in a panic!()
.
We agree about unwrap
and have been removing them over time and trying to avoid adding them (though some slip through; we ain't perfect :). I'll have a look at this one in particular, and at your pull request.
Thanks!
@epgts I am glad to hear it! I used unwrap all the time at first until I got a little more understanding. I think a lot of this is also from the 3rd party library you sourced from GitHub :-) I'll fix the lint thing when I get a minute. I think my clippy or ktlint is stale.