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

feat(redshift): columns require an id attribute (under feature flag) #24272

Merged
merged 32 commits into from
Mar 2, 2023
Merged

feat(redshift): columns require an id attribute (under feature flag) #24272

merged 32 commits into from
Mar 2, 2023

Conversation

Rizxcviii
Copy link
Contributor

@Rizxcviii Rizxcviii commented Feb 22, 2023

Adds an id attribute to retain tables on changing of the column name. This will essentially fire an ALTER statement to rename the column, whilst persisting the id, so columns cannot be dropped.

Closes #24234.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Feb 22, 2023

@github-actions github-actions bot added effort/medium Medium work item – several days of effort repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK feature-request A feature should be added or improved. p2 labels Feb 22, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team February 22, 2023 12:11
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation dismissed their stale review February 22, 2023 12:23

✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.

Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

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

Even though this is module isn't stable, I think we need a feature flag on this. The change itself will cause a replacement and I don't want customers to unintentionally lose data due to a change that is meant to prevent that very thing.

@Rizxcviii
Copy link
Contributor Author

Rizxcviii commented Feb 23, 2023

The change itself will cause a replacement and I don't want customers to unintentionally lose data due to a change that is meant to prevent that very thing.

@TheRealAmazonKendra I don't think it will, since I perform a check to see if the oldColumn.id is defined. If the attribute is not defined by the developer, then we compare using the current Boolean expression.
For example,

column => oldColumn.name !== column.name

now becomes

column => oldColumn.id ? oldColumn.id !== column.id : oldColumn.name !== column.name

This should ensure backwards compatibility, unless I am mistaken.

@MrArnoldPalmer
Copy link
Contributor

@Rizxcviii so that part in the custom resource logic seems to be non-breaking but the new id prop on column is not optional, so users would have to provide an ID where there was a name before. Will that still not cause replacement and if not then the ID just isn't being handled for users with existing columns at all?

@Rizxcviii
Copy link
Contributor Author

@MrArnoldPalmer
Are you referring to the initial assignment of the id when users are forced to give an id to a column? If so, then I think the logic within the code will handle this correctly? Within the logic, the newly assigned id will belong to the column object, but oldColumn.id will still be undefined, since this was not specified in the previous deployment.

Or are you referring to the id "replacing" the name prop. The purpose of the id prop is to be persistent, so the id will never change throughout the initial assignment. My logic is to keep the id static, so thereafter whenever the name changes, the column name on redshift can be altered, whilst still persisting the existing column.
The id prop will take over the responsibility of the names responsibility of being persistent, to maintain column data; but will allow the name of a column to be changed, essentially renaming it on Redshift.
Again, if there is another side effect that I am overlooking, then please correct me.

@Rizxcviii
Copy link
Contributor Author

Actually, now that I'm thinking about it, you are right. If within that initial deployment, the user assumes that the id is persistent, they may change the name attribute, which will effectively drop their column. I will add a feature flag to address the issue @TheRealAmazonKendra @MrArnoldPalmer

@TheRealAmazonKendra
Copy link
Contributor

Actually, now that I'm thinking about it, you are right. If within that initial deployment, the user assumes that the id is persistent, they may change the name attribute, which will effectively drop their column. I will add a feature flag to address the issue @TheRealAmazonKendra @MrArnoldPalmer

Great, thank you!

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review February 27, 2023 17:45

Pull request has been modified.

Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

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

Just one minor comment, but this looks very good!

packages/@aws-cdk/aws-redshift/lib/table.ts Show resolved Hide resolved
@mergify mergify bot dismissed comcalvi’s stale review March 1, 2023 21:56

Pull request has been modified.

Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

Just a test change.

@mergify mergify bot dismissed MrArnoldPalmer’s stale review March 2, 2023 12:04

Pull request has been modified.

@Rizxcviii Rizxcviii requested a review from comcalvi March 2, 2023 12:05
@MrArnoldPalmer MrArnoldPalmer added the pr/do-not-merge This PR should not be merged at this time. label Mar 2, 2023
MrArnoldPalmer
MrArnoldPalmer previously approved these changes Mar 2, 2023
Copy link
Contributor

@MrArnoldPalmer MrArnoldPalmer left a comment

Choose a reason for hiding this comment

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

LGTM! @comcalvi added dnm for you to check out again if needed.

@mergify mergify bot dismissed MrArnoldPalmer’s stale review March 2, 2023 16:51

Pull request has been modified.

Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

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

lgtm! Nice work!

@comcalvi comcalvi removed the pr/do-not-merge This PR should not be merged at this time. label Mar 2, 2023
@mergify
Copy link
Contributor

mergify bot commented Mar 2, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 89bcc7c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 9a07ab0 into aws:main Mar 2, 2023
@mergify
Copy link
Contributor

mergify bot commented Mar 2, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@Rizxcviii Rizxcviii deleted the feature/persist-column-name-change branch March 2, 2023 20:03
@Rizxcviii Rizxcviii restored the feature/persist-column-name-change branch March 2, 2023 20:03
@Rizxcviii Rizxcviii deleted the feature/persist-column-name-change branch March 2, 2023 20:55
@Rizxcviii Rizxcviii restored the feature/persist-column-name-change branch March 2, 2023 20:57
@Rizxcviii Rizxcviii deleted the feature/persist-column-name-change branch March 4, 2023 00:02
homakk pushed a commit to homakk/aws-cdk that referenced this pull request Mar 28, 2023
…ws#24272)

Adds an `id` attribute to retain tables on changing of the column name. This will essentially fire an `ALTER` statement to rename the column, whilst persisting the id, so columns cannot be dropped.

Closes aws#24234.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws-redshift: allow changing of table column names
5 participants