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

Flink 1.17: Support alter table column #7628

Merged
merged 15 commits into from
Sep 27, 2023

Conversation

linyanghao
Copy link
Contributor

@linyanghao linyanghao commented May 17, 2023

Resolves #7312

@github-actions github-actions bot added the flink label May 17, 2023
@linyanghao linyanghao force-pushed the flink-alter-schema branch 2 times, most recently from d4d75bc to fe3521b Compare May 22, 2023 06:38
@linyanghao linyanghao marked this pull request as ready for review May 22, 2023 06:39
@linyanghao
Copy link
Contributor Author

For backward-compatibility, I'm currently remaining the old alterTable API as it is. Not sure if it's the right thing to do.
@hililiwei @stevenzwu @chenjunjiedada Could you take a look at this? Thanks!

@linyanghao linyanghao changed the title Flink: Support alter table column Flink 1.17: Support alter table column May 22, 2023
Copy link
Collaborator

@chenjunjiedada chenjunjiedada left a comment

Choose a reason for hiding this comment

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

+1. @stevenzwu you may also be interested in this.

@linyanghao
Copy link
Contributor Author

@chenjunjiedada Thanks for reviewing! I just fixed a bug on modifying the nullability of columns. You might want to check.

pendingUpdate.deleteColumn(dropColumn.getColumnName());

} else if (change instanceof TableChange.AddWatermark) {
throw new UnsupportedOperationException("Adding watermark specs is not supported yet. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: empty space in the end is not necessary. please check all places

Copy link
Contributor

Choose a reason for hiding this comment

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

this (the extra whitespace in the end) needs to be addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

also the error msg doesn't follow the coding style. you can referring to ArrowVectorAccessor for examples. Please review all the error msgs in this class

E.g., it could be sth like Unsupported schema change: adding watermark specs

if (!schemaChanges.isEmpty()) {
UpdateSchema updateSchema = transaction.updateSchema();
FlinkAlterTableUtil.applySchemaChanges(updateSchema, schemaChanges);
updateSchema.commit();
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe commit action can be moved inside FlinkAlterTableUtil? then it would be more natural to move applyManageSnapshots into FlinkAlterTableUtil too as mentioned in a comment below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's reasonable.

throw new UnsupportedOperationException("Modifying watermark specs is not supported yet. ");

} else if (change instanceof TableChange.DropWatermark) {
throw new UnsupportedOperationException("Watermark specs is not supported yet. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the previous exception message indicated the action to be taken, such as add, modify, but there is no. Should unify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this!

}

@Test
public void testAlterTableAddColumn() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to add a case to test when the name of the field to be added already exists?

@linyanghao
Copy link
Contributor Author

@stevenzwu @hililiwei Thanks for reviewing! I added a few patches. Could you take a look?

@linyanghao
Copy link
Contributor Author

Hi @stevenzwu @hililiwei, do you have any more comments on this?

Copy link
Contributor

@stevenzwu stevenzwu left a comment

Choose a reason for hiding this comment

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

@linyanghao this looks very close to me. just left some minor/nit comments

@linyanghao
Copy link
Contributor Author

@stevenzwu I addressed the comments. Regarding the warning message, I modified it so that users will only see it when they try altering schema using the old API. Could you take a look? Thanks!

pendingUpdate.deleteColumn(dropColumn.getColumnName());

} else if (change instanceof TableChange.AddWatermark) {
throw new UnsupportedOperationException("Adding watermark specs is not supported yet. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

this (the extra whitespace in the end) needs to be addressed.

pendingUpdate.deleteColumn(dropColumn.getColumnName());

} else if (change instanceof TableChange.AddWatermark) {
throw new UnsupportedOperationException("Adding watermark specs is not supported yet. ");
Copy link
Contributor

Choose a reason for hiding this comment

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

also the error msg doesn't follow the coding style. you can referring to ArrowVectorAccessor for examples. Please review all the error msgs in this class

E.g., it could be sth like Unsupported schema change: adding watermark specs

@stevenzwu
Copy link
Contributor

@linyanghao I left a few comments. can you also rebase?

@linyanghao
Copy link
Contributor Author

@stevenzwu Hi, I rebased and addressed the style issues you mentioned. Could you check?

@stevenzwu stevenzwu merged commit 1e52f2e into apache:master Sep 27, 2023
13 checks passed
@stevenzwu
Copy link
Contributor

stevenzwu commented Sep 27, 2023

thanks @linyanghao for the contribution and @chenjunjiedada and @hililiwei for the review.

@linyanghao can you create a back port PR? you can follow the example here for back port: #8228

@linyanghao
Copy link
Contributor Author

@stevenzwu Sure. Thanks for reviewing! Also thanks @chenjunjiedada and @hililiwei for reviewing!

@linyanghao
Copy link
Contributor Author

@stevenzwu Wait, Flink does not support ALTER TABLE in 1.16 yet. I guess we don't need to backport?

@stevenzwu
Copy link
Contributor

if that's the case, yeah no need to back port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Flink's alter table column
4 participants