-
Notifications
You must be signed in to change notification settings - Fork 972
Fix gapfill bug when aggregates are in expressions with groupby columns #8550
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
Fix gapfill bug when aggregates are in expressions with groupby columns #8550
Conversation
@dbeck, @mkindahl: please review this pull request.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8550 +/- ##
==========================================
+ Coverage 82.37% 82.48% +0.10%
==========================================
Files 248 248
Lines 47632 47633 +1
Branches 12101 12104 +3
==========================================
+ Hits 39237 39289 +52
- Misses 3503 3507 +4
+ Partials 4892 4837 -55 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
abcc4c1
to
428a9cc
Compare
One thing I don't understand about this: suppose you have |
Looks like this is still not correct:
|
When we have aggregates, the only vars which can be used in the target list are aggregates and grouping columns. Grouping columns are guaranteed to be computed and provided by the aggregate node. I.e. |
We need to cover any grouping expressions, not just vars. Will look into it. |
428a9cc
to
2be902f
Compare
Fix gapfill bug when aggregates are in expressions with groupby columns, use custom_exprs
2be902f
to
554622c
Compare
…ns (#8550) Fixes #4894 Gapfill used to error out when aggregates were used in expressions with group-by columns like `(agg + gby_var)` and when gapfill target entries were not matching the table column order. It is fixed by fixing group-by vars to match execution group-by vars. (cherry picked from commit 6e0e00d)
…ns (#8550) Fixes #4894 Gapfill used to error out when aggregates were used in expressions with group-by columns like `(agg + gby_var)` and when gapfill target entries were not matching the table column order. It is fixed by fixing group-by vars to match execution group-by vars. (cherry picked from commit 6e0e00d)
## 2.22.1 (2025-09-30) This release contains performance improvements and bug fixes since the [2.22.0](https://github.com/timescale/timescaledb/releases/tag/2.20.0) release. We recommend that you upgrade at the next available opportunity. This release blocks the ability to leverage **concurrent refresh policies** in **hierarchical continous aggregates**, as potential deadlocks can occur. If you have [concurrent refresh policies](https://docs.tigerdata.com/use-timescale/latest/continuous-aggregates/refresh-policies/#add-concurrent-refresh-policies) in **hierarchical** continous aggregates, [please disable the jobs](https://docs.tigerdata.com/api/latest/jobs-automation/alter_job/#samples), as following: ``` SELECT alter_job("<job_id_of_concurrent_policy>", scheduled => false); ``` **Bugfixes** * [#7766](#7766) Load OSM extension in retention background worker to drop tiered chunks * [#8550](#8550) Error in gapfill with expressions over aggregates and groupby columns and out-of-order columns * [#8593](#8593) Error on change of invalidation method for continuous aggregate * [#8599](#8599) Fix attnum mismatch bug in chunk constraint checks * [#8607](#8607) Fix interrupted continous aggregate refresh materialization phase leaving behind pending materialization ranges * [#8638](#8638) `ALTER TABLE RESET` for `orderby` settings * [#8644](#8644) Fix migration script for sparse index configuration * [#8657](#8657) Fix `CREATE TABLE WITH` when using UUIDv7 partitioning * [#8659](#8659) Don't propagate `ALTER TABLE` commands to foreign data wrapper chunks * [#8693](#8693) Compressed index not chosen for `varchar` typed `segmentby` columns * [#8707](#8707) Block concurrent refresh policies for hierarchical continous aggregate due to potential deadlocks **Thanks** * @MKrkkl for reporting a bug in Gapfill queries with expressions over aggregates and groupby columns * @brandonpurcell-dev for creating a test case that showed a bug in `CREATE TABLE WITH` when using UUIDv7 partitioning * @snyrkill for reporting a bug when interrupting a continous aggregate refresh --------- Signed-off-by: Philip Krauss <[email protected]> Co-authored-by: timescale-automation <123763385+github-actions[bot]@users.noreply.github.com> Co-authored-by: philkra <[email protected]> Co-authored-by: Philip Krauss <[email protected]> Co-authored-by: Iain Cox <[email protected]>
## 2.22.1 (2025-09-30) This release contains performance improvements and bug fixes since the [2.22.0](https://github.com/timescale/timescaledb/releases/tag/2.20.0) release. We recommend that you upgrade at the next available opportunity. This release blocks the ability to leverage **concurrent refresh policies** in **hierarchical continous aggregates**, as potential deadlocks can occur. If you have [concurrent refresh policies](https://docs.tigerdata.com/use-timescale/latest/continuous-aggregates/refresh-policies/#add-concurrent-refresh-policies) in **hierarchical** continous aggregates, [please disable the jobs](https://docs.tigerdata.com/api/latest/jobs-automation/alter_job/#samples), as following: ``` SELECT alter_job("<job_id_of_concurrent_policy>", scheduled => false); ``` **Bugfixes** * [#7766](#7766) Load OSM extension in retention background worker to drop tiered chunks * [#8550](#8550) Error in gapfill with expressions over aggregates and groupby columns and out-of-order columns * [#8593](#8593) Error on change of invalidation method for continuous aggregate * [#8599](#8599) Fix attnum mismatch bug in chunk constraint checks * [#8607](#8607) Fix interrupted continous aggregate refresh materialization phase leaving behind pending materialization ranges * [#8638](#8638) `ALTER TABLE RESET` for `orderby` settings * [#8644](#8644) Fix migration script for sparse index configuration * [#8657](#8657) Fix `CREATE TABLE WITH` when using UUIDv7 partitioning * [#8659](#8659) Don't propagate `ALTER TABLE` commands to foreign data wrapper chunks * [#8693](#8693) Compressed index not chosen for `varchar` typed `segmentby` columns * [#8707](#8707) Block concurrent refresh policies for hierarchical continous aggregate due to potential deadlocks **Thanks** * @MKrkkl for reporting a bug in Gapfill queries with expressions over aggregates and groupby columns * @brandonpurcell-dev for creating a test case that showed a bug in `CREATE TABLE WITH` when using UUIDv7 partitioning * @snyrkill for reporting a bug when interrupting a continous aggregate refresh --------- Signed-off-by: Philip Krauss <[email protected]> Co-authored-by: timescale-automation <123763385+github-actions[bot]@users.noreply.github.com> Co-authored-by: philkra <[email protected]> Co-authored-by: Philip Krauss <[email protected]> Co-authored-by: Iain Cox <[email protected]>
Fixes #4894
Gapfill used to error out when aggregates were used in expressions with group-by columns like
(agg + gby_var)
and when gapfill target entries were not matching the table column order.It is fixed by fixing group-by vars to match execution group-by vars.