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

Rename columns in old-style continuous aggregates #5367

Merged
merged 1 commit into from
Mar 3, 2023

Conversation

mkindahl
Copy link
Contributor

@mkindahl mkindahl commented Feb 28, 2023

For continuous aggregates with the old-style partial aggregates renaming columns that are not in the group-by clause will generate an error when upgrading to a later version. The reason is that it is implicitly assumed that the name of the column is the same as for the direct view. This holds true for new-style continous aggregates, but is not true for old-style continuous aggregates.

This commit fixes that by extracting the name of the column from the partial view and use that when renaming the partial view column and the materialized table column.

Fixes #5348

@codecov
Copy link

codecov bot commented Feb 28, 2023

Codecov Report

Merging #5367 (1dfee42) into main (e6f6eb3) will decrease coverage by 0.17%.
The diff coverage is n/a.

❗ Current head 1dfee42 differs from pull request most recent head b97d3a8. Consider uploading reports for the commit b97d3a8 to get more accurate results

@@            Coverage Diff             @@
##             main    #5367      +/-   ##
==========================================
- Coverage   90.84%   90.68%   -0.17%     
==========================================
  Files         226      226              
  Lines       46291    52517    +6226     
==========================================
+ Hits        42052    47623    +5571     
- Misses       4239     4894     +655     
Impacted Files Coverage Δ
tsl/test/src/test_chunk_stats.c 92.59% <0.00%> (-7.41%) ⬇️
src/uuid.c 78.57% <0.00%> (-6.05%) ⬇️
tsl/src/remote/healthcheck.c 63.76% <0.00%> (-6.05%) ⬇️
src/planner/add_hashagg.c 48.95% <0.00%> (-5.33%) ⬇️
src/histogram.c 83.83% <0.00%> (-4.80%) ⬇️
src/extension_utils.c 90.74% <0.00%> (-4.72%) ⬇️
tsl/src/fdw/fdw_utils.c 80.76% <0.00%> (-4.65%) ⬇️
src/time_utils.c 93.72% <0.00%> (-3.78%) ⬇️
tsl/src/remote/copy_fetcher.c 87.00% <0.00%> (-3.65%) ⬇️
src/utils.h 80.00% <0.00%> (-3.34%) ⬇️
... and 192 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@mkindahl mkindahl force-pushed the cagg-partial-upgrade branch 3 times, most recently from 1dfee42 to 1a5a430 Compare February 28, 2023 13:39
For continuous aggregates with the old-style partial aggregates
renaming columns that are not in the group-by clause will generate an
error when upgrading to a later version. The reason is that it is
implicitly assumed that the name of the column is the same as for the
direct view. This holds true for new-style continous aggregates, but is
not always true for old-style continuous aggregates. In particular,
columns that are not part of the `GROUP BY` clause can have an
internally generated name.

This commit fixes that by extracting the name of the column from the
partial view and use that when renaming the partial view column and the
materialized table column.
@mkindahl mkindahl marked this pull request as ready for review February 28, 2023 13:54
@github-actions
Copy link

@akuzm, @konskov: please review this pull request.

Powered by pull-review

Comment on lines +156 to +158
\if :has_cagg_rename_col_bug == false
ALTER MATERIALIZED VIEW rename_cols RENAME COLUMN humidity TO moisture;
\endif
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the 2.5.x series has a bug that prevents renaming column that are not in the GROUP BY clause, so we do not test to rename the columns for this version. It does not pose an upgrade problem since users cannot even rename the columns for this version.

@mkindahl mkindahl merged commit a6ff7ba into timescale:main Mar 3, 2023
@mkindahl mkindahl deleted the cagg-partial-upgrade branch March 3, 2023 13:02
@mkindahl mkindahl added this to the TimescaleDB 2.10.1 milestone Mar 3, 2023
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Mar 6, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5362 Make copy fetcher more async
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5317 Fix some incorrect memory handling
* timescale#5367 Rename columns in old-style continuous aggregates
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5343 Set PortalContext when starting job
* timescale#5360 Fix uninitialized bucket_info variable
* timescale#5362 Make copy fetcher more async
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5367 Fix column name handling in old-style continuous aggregates
* timescale#5378 Fix multinode DML HA performance regression
* timescale#5384 Fix Hierarchical Continuous Aggregates chunk_interval_size
* timescale#5153 Fix concurrent locking with chunk_data_node table

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
@svenklemm svenklemm mentioned this pull request Mar 6, 2023
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Mar 6, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5362 Make copy fetcher more async
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5317 Fix some incorrect memory handling
* timescale#5367 Rename columns in old-style continuous aggregates
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5343 Set PortalContext when starting job
* timescale#5360 Fix uninitialized bucket_info variable
* timescale#5362 Make copy fetcher more async
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5367 Fix column name handling in old-style continuous aggregates
* timescale#5378 Fix multinode DML HA performance regression
* timescale#5384 Fix Hierarchical Continuous Aggregates chunk_interval_size
* timescale#5153 Fix concurrent locking with chunk_data_node table

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Mar 6, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#5159 Support Continuous Aggregates names in hypertable_(detailed_)size
* timescale#5226 Fix concurrent locking with chunk_data_node table
* timescale#5317 Fix some incorrect memory handling
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5343 Set PortalContext when starting job
* timescale#5360 Fix uninitialized bucket_info variable
* timescale#5362 Make copy fetcher more async
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5367 Fix column name handling in old-style continuous aggregates
* timescale#5378 Fix multinode DML HA performance regression
* timescale#5384 Fix Hierarchical Continuous Aggregates chunk_interval_size

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
svenklemm added a commit that referenced this pull request Mar 7, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #5159 Support Continuous Aggregates names in hypertable_(detailed_)size
* #5226 Fix concurrent locking with chunk_data_node table
* #5317 Fix some incorrect memory handling
* #5336 Use NameData and namestrcpy for names
* #5343 Set PortalContext when starting job
* #5360 Fix uninitialized bucket_info variable
* #5362 Make copy fetcher more async
* #5364 Fix num_chunks inconsistency in hypertables view
* #5367 Fix column name handling in old-style continuous aggregates
* #5378 Fix multinode DML HA performance regression
* #5384 Fix Hierarchical Continuous Aggregates chunk_interval_size

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
svenklemm added a commit to svenklemm/timescaledb that referenced this pull request Mar 7, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* timescale#5159 Support Continuous Aggregates names in hypertable_(detailed_)size
* timescale#5226 Fix concurrent locking with chunk_data_node table
* timescale#5317 Fix some incorrect memory handling
* timescale#5336 Use NameData and namestrcpy for names
* timescale#5343 Set PortalContext when starting job
* timescale#5360 Fix uninitialized bucket_info variable
* timescale#5362 Make copy fetcher more async
* timescale#5364 Fix num_chunks inconsistency in hypertables view
* timescale#5367 Fix column name handling in old-style continuous aggregates
* timescale#5378 Fix multinode DML HA performance regression
* timescale#5384 Fix Hierarchical Continuous Aggregates chunk_interval_size

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
svenklemm added a commit that referenced this pull request Mar 7, 2023
This release contains bug fixes since the 2.10.0 release.
We recommend that you upgrade at the next available opportunity.

**Bugfixes**
* #5159 Support Continuous Aggregates names in hypertable_(detailed_)size
* #5226 Fix concurrent locking with chunk_data_node table
* #5317 Fix some incorrect memory handling
* #5336 Use NameData and namestrcpy for names
* #5343 Set PortalContext when starting job
* #5360 Fix uninitialized bucket_info variable
* #5362 Make copy fetcher more async
* #5364 Fix num_chunks inconsistency in hypertables view
* #5367 Fix column name handling in old-style continuous aggregates
* #5378 Fix multinode DML HA performance regression
* #5384 Fix Hierarchical Continuous Aggregates chunk_interval_size

**Thanks**
* @justinozavala for reporting an issue with PL/Python procedures in the background worker
* @Medvecrab for discovering an issue with copying NameData when forming heap tuples.
* @pushpeepkmonroe for discovering an issue in upgrading old-style
  continuous aggregates with renamed columns
* @pushpeepkmonroe for discovering an issue in upgrading old-style continuous aggregates with renamed columns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Upgrading timescale with partial aggregate continuous aggregate fails
4 participants