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 #837

Open
relativityboy opened this issue Jun 5, 2024 · 0 comments
Open
Labels
bug Something isn't working

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)
@relativityboy relativityboy added the bug Something isn't working label Jun 5, 2024
@antekresic antekresic transferred this issue from timescale/timescaledb Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant