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

[Bug]: average(time_weight('linear')) yields incorrect result #6999

Open
relativityboy opened this issue Jun 5, 2024 · 0 comments
Open

[Bug]: average(time_weight('linear')) yields incorrect result #6999

relativityboy opened this issue Jun 5, 2024 · 0 comments

Comments

@relativityboy
Copy link

What type of bug is this?

Incorrect result

What subsystems and features are affected?

Continuous aggregate

What happened?

When creating a 1-minute materialized view where the value col is average(time_weighted('linear' ... )) as value with 3 entries in the source data table at (seconds, value) [(0,1), (10, 11), (50, 51)] the expected output for the time weighted average is 30.17.

Expected equivalent calculation (((1 + 11) / 2) * 10 + ((11 + 51) / 2) * 40 + ((51 + 51) / 2) * 10) / 60

The materialized view yields a value of 26.0

TimescaleDB version affected

2.14.2

PostgreSQL version used

15.6

What operating system did you use?

MacOS

What installation method did you use?

Docker

What platform did you run on?

On prem/Self-hosted

Relevant log output and stack trace

No response

How can we reproduce the bug?

Create a materialized view at 1 minute agg pulling data from a table with start_time, value columns. Create aggregation with value as described above. (actual sql is on work machine and not sure if I'm allowed to share)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants