-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-25176][table] Introduce "ALTER TABLE ... COMPACT" syntax #18236
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
Conversation
|
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit bac3a83 (Wed Dec 29 15:16:33 UTC 2021) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. DetailsThe Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
|
|
||
| public Map<String, String> getPartitionSpec() { | ||
| return partitionSpec == null | ||
| ? new LinkedHashMap<>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, is it important to return a new empty instance or we can just return java.util.Collections.emptyMap()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. We'd better return Collections.emptyMap(). It just hadn't hit me yet at that time.
JingsongLi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @LadyForest for your contribution, left some comments.
Can you separate to two commits? The first one is Fix some error and change tests to junit5, the second one is Introduce ALTER...... In that way, can be more clear.
| Catalog catalog = | ||
| catalogManager | ||
| .getCatalog(tableIdentifier.getCatalogName()) | ||
| .orElseThrow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orElse(null).
isManagedTable accepts nullable catalog.
We can throws exception to a unified mode in below.
| List<String> orderedPartitionKeys = resolvedCatalogTable.getPartitionKeys(); | ||
| int index = 0; | ||
| String exMsg = | ||
| orderedPartitionKeys.isEmpty() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, maybe it doesn't have to be ordered, just hit the specified partition is OK.
We can just do something like DynamicSinkUtils.validatePartitioning
| } | ||
| return new AlterTableCompactOperation(tableIdentifier, partitionSpec); | ||
| } | ||
| throw new UnsupportedOperationException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidationException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidationException?
I'm fine with that.
059fb3d to
980177f
Compare
|
Hi @JingsongLi, I've addressed your comments. Would you mind taking another look? |
JingsongLi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @LadyForest for your update. Looks good to me!
What is the purpose of the change
This PR is a foundation of FLINK-25176 that introduces the SQL syntax
ALTET TABLE table_identifier [PARTITION partition_spec] COMPACT, which paves the way for coordination with managed table storage. You can find more details at FLIP-188.Brief changelog
This PR contains two commits
69a521d
UseCatalogOperation{@link}inPartitioningSpec(which I've confirmed with @godfreyhe)asSummaryStringmethod inAlterTableDropConstraintOperationto usetableIdentifier.asSummaryStringbecausetableIdentifier.toStirngis implicitly calltableIdentifier.asSerializableStringSqlToOperationConverterTestto assertJ980177f
Parser.tddandparserImpls.ftltemplates for flink-sql-parser to support syntax. AddSqlAlterTableCompactas the representition after parsing.SqlToOperationConverterto support operation transformation. The converter imposes a check on the underlying table is a Flink's managed table and throws aValidationExceptionif it is a non-managed one. The converter also checks the partition spec and throws aValidationExceptionif the partition_spec is invalid.ALTER TABLE RESETfrom removing theconnectoroption key.Verifying this change
This change added tests and can be verified as follows:
FlinkSqlParserImplTestto verify the syntax parsingSqlToOperationConverterTestto verify the operation conversionDoes this pull request potentially affect one of the following parts:
@Public(Evolving): (yes / no)Documentation