Skip to content

Hyperfunction returns wrong value for large bigint valuesΒ #871

@Darti12

Description

@Darti12

Relevant system information:

  • OS: macOS 15.4.1
  • PostgreSQL version (output of SELECT version();): 17.4
  • TimescaleDB Toolkit version (output of \dx timescaledb_toolkit in psql): 1.21.0
  • Installation method: docker

Describe the bug
When stats_agg is run on large bigint values like 5223372036854775805 and 5223372036854775806 that approach the limit of bigint, hyperfunctions like average return the wrong value.

To Reproduce
Steps to reproduce the behavior:
Run this SQL:
SELECT average(stats_agg(data)) FROM generate_series(5223372036854775805::bigint, 5223372036854775806) data;

Expected behavior
Either an overflow error if not supported, or a workaround using decimal or numeric value types.

Actual behavior
For the stated reproduction the result is '5223372036854775800'. The actual result should be '5223372036854775805.5'

Screenshots
Image

Image

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