Skip to content

Time-weighted rollup: called Result::unwrap() on an Err value: OrderError #839

@michael-sayapin

Description

@michael-sayapin

Relevant system information:

  • OS: Ubuntu 22.04
  • PostgreSQL version (output of SELECT version();): PostgreSQL 14.15 (Ubuntu 14.15-1.pgdg22.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
  • TimescaleDB Toolkit version (output of \dx timescaledb_toolkit in psql): 1.19.0
  • Installation method: Docker timescale/timescaledb-ha:pg14-ts2.17

Describe the bug

Time-weighted average rollup cannot rollup disjointed data.

# SELECT time_bucket('9999y', t), rollup(tw_column) FROM my_cagg GROUP BY 1;
ERROR:  called `Result::unwrap()` on an `Err` value: OrderError

I tried:

  • adding a CTE or subquery to filter tw_column IS NOT NULL
  • ordering by t in CTE / subquery

The issue can be reproduced when I have two records like this:

        t               |                                                                                 tw_column
------------------------+----------------------------------------------------------------------------------------------------
 2025-01-14 01:00:00+00 | (version:1,first:(ts:"2025-01-14 01:00:24+00",val:1),last:(ts:"2025-01-14 01:59:25+00",val:2),weighted_sum:5,method:Linear)
 2025-01-14 01:00:00+00 | (version:1,first:(ts:"2025-01-14 01:00:25+00",val:3),last:(ts:"2025-01-14 01:59:25+00",val:4),weighted_sum:7,method:Linear)

Expected behavior

Merging of two time-weighted aggregates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions